
Hicham Mouline a écrit :
hello, There is an example listed in "C++ template metaprogramming" to generate a class with its members from an mpl sequence:
template <typename T> struct wrap { typedef T value; };
typedef mpl::vector< type1, type2, type3 > member_types; mpl::inherit_linearly< member_types, mpl::inherit< wrap<_2>, _1 > >::type generated;
but then, the generated class did not look like this:
class C { type1 t1; type2 t2; type3 t3; };
Can one do that with BOOST_PP and sequences from preprocessor libs instead?
Yes, something like : #define MEMBER(z,n,text) BOOST_PP_CAT(text,n) BOOST_PP_CAT(t,n); class C { BOOST_PP_ENUM_(3,MEMBER,type) }; A more generic version can be done if you pass a tuple of symbol as ENUM data -- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35