dimanche 26 juillet 2015

Fusion adaped std_tuple views, conversion to another tuple

Boost Fusion has been designed in such a way that most of the transformations are "lazy", in the sense that they all generate "views" but not actual (or standard containers). So for example to actually reverse a vector one needs to use the function as_vector.

boost::fusion::vector<int, double, std::string> vec;
auto view_rev = boost::fusion::reverse(vec); // view object
auto vec_rev = boost::fusion::as_vector(view_rev);

Now, I want to do this with adapted std::tuple:

#include<boost/fusion/adapted/std_tuple.hpp>
...
std::tuple<int, double, std::string> tup;
auto view_rev = boost::fusion::reverse(tup);
auto tup_rev = boost::fusion::???(view_rev); // type should be of type std::tuple<std::string, double, int>

How do I convert the resulting view back to a tuple?

I expected this ??? function to be called to_std_tuple, but it doesn't exists (yet?).

There a few solutions for reversing tuples, in this case I want just to use what is already in Boost Fusion.

Aucun commentaire:

Enregistrer un commentaire