#include #include #include #include #include #include #include typedef std::vector int_vector; namespace { template typename Func::return_type to_compile_time(int i, boost::mpl::true_) { if (i == Begin::value) return Func::apply(i); else return to_compile_time(i); } template typename Func::return_type to_compile_time(int, boost::mpl::false_) { return Func::return_type(); } template typename Func::return_type to_compile_time(int i) { return to_compile_time(i, boost::mpl::less()); } } template struct get_at { typedef int return_type; template static return_type apply(int) { return boost::mpl::at::type::value; } }; template int_vector to_runtime() { const int size = boost::mpl::size::type::value; int_vector ret; ret.reserve(size); for (int i = 0; i < size; ++i) { ret.push_back( to_compile_time < get_at, boost::mpl::int_<0>, typename boost::mpl::size::type >(i)); } return ret; } BOOST_AUTO_UNIT_TEST(test_compile_time_int_vector_to_runtime_int_vector) { typedef boost::mpl::vector_c c_list; int_vector r_list = to_runtime(); BOOST_CHECK((boost::mpl::size::type::value == r_list.size())); BOOST_CHECK((boost::mpl::at_c::type::value == r_list[0])); BOOST_CHECK((boost::mpl::at_c::type::value == r_list[1])); BOOST_CHECK((boost::mpl::at_c::type::value == r_list[2])); BOOST_CHECK((boost::mpl::at_c::type::value == r_list[3])); BOOST_CHECK((boost::mpl::at_c::type::value == r_list[4])); BOOST_CHECK((boost::mpl::at_c::type::value == r_list[5])); }