With C ++ 11, I have something like
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/size.hpp>
#include <boost/array.hpp>
#include <iostream>
namespace mpl = boost::mpl;
template<std::size_t ... Args>
struct Test
{
typedef mpl::vector_c<std::size_t, Args ...> values_type;
static const boost::array<std::size_t, sizeof...(Args)> values;
};
int main (int argc, char** argv)
{
Test<3,2,5,6,7> test;
return 0;
}
I would like to initialize the contents of boost :: array with the values contained in mpl :: vector_c. This initialization must be performed at compile time. I have seen on SO some solutions using the preprocessor, but I have no idea how to apply them to the case of the variation pattern.
Note that in the above code example, the elements mpl :: vector_c match the parameters of the test pattern. In the actual code, this is not the case , instead it values_typehas a length == of the number of template arguments, but the actual values are the result of applying a sequence of mpl algorithms. Therefore, do not assume that the argument is the same.
, , !