Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

boost hana zip two sequences into map

static constexpr auto type_tuple_c = hana::tuple_t<T...>;
static constexpr auto idx_tuple_c = hana::tuple_c<std::size_t, 0, sizeof...(T)>;

I'd like to map these two sequences of equal sizes with each other. However, I can't seem to understand how to get that with the hana::map features:

static constexpr auto type_idx_map_c = hana::unpack(
    hana::zip_with(hana::make_pair, type_tuple_c, idx_tuple_c)
  , hana::make_map
);

No matter what transformations I make, I can't seem to create the mapping. I understand that a map requires its elements to be of the Product concept, but I can't seem to get (or even understand) that behavior in regards to zipped structures.

Is there anything I can do, or anything I'm doing incorrectly?

Running gcc version 6.0.0 20160320 and hana version 0.7.0 last fetched today

like image 237
Brian Rodriguez Avatar asked Apr 10 '16 21:04

Brian Rodriguez


1 Answers

I'd like to map these two sequences of equal sizes with each other.

Those sequences aren't typically of equal sizes. type_tuple_c has size sizeof...(T), but idx_tuple_c has size 2 - it only contains the elements hana::size_c<0> and hana::size_c<sizeof...(T)>.

I think what you're looking for as far as indices go is just std::make_index_sequence<sizeof...(T)>{}. That should still play well with Boost.Hana.

like image 95
Barry Avatar answered Nov 06 '22 11:11

Barry