I have a template class which accepts a tuple of pairs of a type and an integral constant (some of the types can be repeated so it can't be a hana::map). I'm looking to iterate over the tuple and call a static toString()
type method defined for each type. The error I am receiving is:
"error: type 'decltype(hana::first(c))' (aka 'boost::hana::type_impl::_ &') cannot be used prior to '::' because it has no members"
struct A
{
static std::string toString() {return std::string("A");}
};
struct B
{
static std::string toString() {return std::string("B");}
};
using namespace hana::literals;
std::array<std::string,3> ret;
constexpr auto tupleOfPairs = hana::make_tuple(
hana::make_pair(hana::type_c<A>, 0_c),
hana::make_pair(hana::type_c<B>, 0_c),
hana::make_pair(hana::type_c<B>, 5_c));
size_t idx = 0;
hana::for_each(tupleOfPairs, [&](auto c)
{
ret[idx++] = decltype(hana::first(c))::type::toString();
});
I had something very similar working when it was just a tuple (using decltype(c)::type::toString()
) but as soon as I made the tuple elements pairs with an integral constant I can't seem to extract the type of the first element of the pair and do the same.
Thanks