Boost mpl::vector and hana

839 views Asked by At

I'm searching some kind of meta vector/linked list. Seems like mpl::vector was the best way of doing this. But now there is hana. Unfortunately I can't find some kind of hana::vector. I saw an adapter for mpl::vector that's all. So that's mean mpl::vector is still the best way of doing things?

Hana was pretty quick to compile so I was like : well why not? But mpl is not that fast, do I really need to code mpl::vector myself?

1

There are 1 answers

5
Vittorio Romeo On BEST ANSWER

boost::hana::tuple should be a good-enough replacement for mpl::vector if what you need is a heterogeneous "list" of types/values.

You can access an item in a particular index with boost::hana::at, append items with boost::hana::append, remove them with boost::hana::remove and much more.

Even if there isn't a 1-to-1 correspondence to mpl::vector's interface, it should be trivial to implement some utility functions given the primitives mentioned above.


If you need a list of types, you should use boost::hana::tuple_t, which is syntactic sugar for hana::tuple(hana::type_c<Types>...).