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!
array_type{{ ... }}
stands for in C++11? I'm just starting to use C++11 features (they really make my life simpler IMO), it is still hard to find a reasonably complete and accessible (for me) account of non-trivial usages of new features (NOT the standard)... – Giuliano May 31 '12 at 10:34