//typelists.cpp #define BOOST_MPL_USE_PREPROCESSED_HEADERS #define BOOST_MPL_LIMIT_VECTOR_SIZE 20 #include #include #include #include #include #include #include #include using namespace std; using namespace boost; //this template class is used to increase the number of types template struct TypeHolder { T held; }; //metafunction to turn a T into TypeHolder template struct make_TypeHolder { typedef TypeHolder type; }; typedef mpl::vector< unsigned char, char, unsigned short, short, unsigned int, int, float, double > ScalarTypes; //make a second vector of types, wrapping TypeHolder around them typedef mpl::transform >::type >::type HeldTypes; //put the two vectors together typedef mpl::insert_range::type, HeldTypes>::type ManyTypes; BOOST_STATIC_ASSERT((mpl::size::type::value == mpl::size::type::value + mpl::size::type::value)); BOOST_STATIC_ASSERT((mpl::size::type::value == 16)); typedef make_variant_over::type variant_type; int main() { int bob = 36; variant_type v(bob); }