5#include <boost/hana/at_key.hpp>
6#include <boost/hana/for_each.hpp>
7#include <boost/hana/keys.hpp>
8#include <boost/hana/map.hpp>
9#include <yaml-cpp/yaml.h>
11#include "hana_fwd.hpp"
16 requires(boost::hana::Struct<T>::value)
17bool convert<T>::decode(
const Node & yaml, T & t)
19 boost::hana::for_each(boost::hana::keys(t), [&](
auto key) {
20 using ValT = std::decay_t<
decltype(boost::hana::at_key(t, key))>;
21 char const * key_c = boost::hana::to<char const *>(key);
22 boost::hana::at_key(t, key) = yaml[key_c].template as<ValT>();
28template<
typename... Ts>
29bool convert<std::variant<Ts...>>::decode(
const Node & yaml, std::variant<Ts...> & obj)
34 boost::hana::for_each(hana_map, [&](
const auto & entry) {
35 if (boost::hana::first(entry) == yaml.Tag()) {
36 using type = std::decay_t<
decltype(boost::hana::second(entry))>::type;
37 obj = yaml.template as<type>();
YAML forward declarations.
Type trait for std::variant<> yaml decoding.