Etherealone Etherealone - 1 year ago 140
C++ Question

Iterating over boost::hana::tuple

I could not find a way to access real object with

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 << << std::endl;

Type of
appears to be
and seems to be not-castable to its underlying 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.

Answer Source

tuple_t is for a tuple of hana::types. You want a tuple of normal objects, which is just tuple:

boost::hana::tuple<A, B> names;
boost::hana::for_each(names, [&](const auto& x) {
    std::cout << << std::endl;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download