On 20/03/2015 17:49, costis glynos wrote:
You also need to use Boost.Fusion to make it into a tuple at the end, since this is what you want.
Here is an example:
#include
#include #include #include #include #include <iostream> int main() { namespace mpl = boost::mpl; namespace fusion = boost::fusion;
typedef mpl::vector
types; typedef mpl::sort mpl::_1 , mpl::sizeof_mpl::_2 > >::type sorted_types; typedef fusion::result_of::as_vector ::type tuple; tuple t; std::cout << sizeof(t) << std::endl; // 8 instead of 12 }
This appears to work.
That's fantastic! Thank you for your recommendation.
You probably need to be able to access the final tuple with the original
indices though, which is a bit more involved.
#include
::type indexes_types; typedef mpl::sort< indexes_types , mpl::less< mpl::sizeof_< mpl::frontmpl::_1 > , mpl::sizeof_< mpl::frontmpl::_2 > > ::type indexes_types_sorted; typedef mpl::transform< indexes_types_sorted , mpl::frontmpl::_1 ::type sorted_types; typedef mpl::transform< indexes_types_sorted , mpl::backmpl::_1 ::type sorted_indexes; typedef fusion::result_of::as_vector
::type tuple;
tuple t;
std::cout << sizeof( fusion::at_c