I could not find a way to access real object with hana::for_each
iterating over tuples.
struct A {
std::string name;
}
struct B {
std::string name;
}
using type_t = decltype(boost::hana::tuple_t<A, B>);
type_t names;
boost::hana::for_each(names, [&](const auto& a) {
std::cout << a.name << std::endl;
});
Type of a
appears to be hana::tuple_impl<...>
and seems to be not-castable to its underlying type decltype(std::decay_t<a>)::type
.
I basically want to iterate over a list of templated objects (containers) that have the same interface but contain different values. Better ways to achieve this is welcome.
decltype(boost::hana::tuple_t<A, B>)
. What does this mean? Isn'ttuple_t<A,B>
a type itself? – Charilyauto types = hana::tuple_t<int*, char&, void>;
So I guess it is a C++14 variable template. boost.org/doc/libs/1_61_0/libs/hana/doc/html/index.html – Indusium