With C++11 i have the 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 boost::array contents with the values 'contained' in the mpl::vector_c. This initialization should be performed at compile time. I have seen on SO some solutions using the preprocessor, but I have no idea on how to apply them to the variadic template case.
Notice that in the above sample code, the elements of the mpl::vector_c are the same as Test's template parameters. In the actual code it is not the case, instead values_type
has length == number of template arguments, but the actual values result from the application of a sequence of mpl algorithms. Therefore, do not assume that the argument are the same.
Hope the question is clear, thanks!
for (size_t s : {3, 2, 5, 6, 7})
? – Gonad