diff --git a/include/yaml-cpp/node/convert.h b/include/yaml-cpp/node/convert.h index f388a67..5b6cc10 100644 --- a/include/yaml-cpp/node/convert.h +++ b/include/yaml-cpp/node/convert.h @@ -241,6 +241,35 @@ struct convert > { } }; +// std::array +template +struct convert > { + static Node encode(const std::array& rhs) { + Node node(NodeType::Sequence); + for (typename std::array::const_iterator it = rhs.begin(); + it != rhs.end(); ++it) + node.push_back(*it); + return node; + } + + static bool decode(const Node& node, std::array& rhs) { + if (!node.IsSequence()) + return false; + + std::size_t index = 0; + for (const_iterator it = node.begin(); it != node.end(); ++it) { +#if defined(__GNUC__) && __GNUC__ < 4 + // workaround for GCC 3: + rhs.at(index) = it->template as(); +#else + rhs.at(index) = it->as(); +#endif + ++index; + } + return true; + } +}; + // std::pair template struct convert > {