
"Paul Mensonides" wrote:
Yeah, that won't work because the preprocessor cannot evaluate 'boost::mpl::size<TTypes>::value'. If you're going to use the preprocessor for this, you need to store the types in a preprocessor data structure, not an mpl::vector. (Note, BTW, than an MPL vector can be trivial created from a preprocessor data structure.)
Thanks for the idea; the program compiles and works fine; it is easy to
maintain since I have only the preprocessor data structure to keep updated
when I add T classes. I am getting some type checking for instance if I add
to the TYPES preprocessor data structure a type that does not exist. MPL and
preprocesor library are great tools!
JCR
#define MY_TYPES (T0) (T1) (T2) (T3) (T4)
typedef boost::mpl::vector ::type); \
break;
BOOST_PP_REPEAT(BOOST_PP_SEQ_SIZE(MY_TYPES), CASES, ~);
}
}
}; "Paul Mensonides" -----Original Message-----
From: boost-users-bounces@lists.boost.org
[mailto:boost-users-bounces@lists.boost.org] On Behalf Of
John Christopher
Sent: Saturday, March 18, 2006 8:26 AM
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] MPL to get rid of cumbersome switch Given its prepetitive nature you could use boost
preprocessor library
to generate this switch... That's a good idea.
I could define
#define NUMBER_CASES 4
and the switch would become something like that:
switch(i)
{
#define CASES(z, n, text)
\
case n:
\
vec.push_back(new boost::mpl::at but this does not compile and I am getting the error Yeah, that won't work because the preprocessor cannot evaluate
'boost::mpl::size<TTypes>::value'. If you're going to use the
preprocessor for
this, you need to store the types in a preprocessor data structure, not an
mpl::vector. (Note, BTW, than an MPL vector can be trivial created from a
preprocessor data structure.) Regards,
Paul Mensonides