Given its prepetitive nature you could use boost preprocessor library to generate this switch...
::type); \ break; BOOST_PP_REPEAT(NUMBER_CASES, CASES, ~); }
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
John Christopher wrote:
Hello, Still reading... Chapter 11 is still a few pages away... Any way, I rewrote the program and I have something much simpler. The vector of types has not changed: typedef boost::mpl::vector
TTypes; but the Functor has a new switch statement that is much easier to maintain. The nnumber of cases in the switch must be the number of elements in the vector of types... Adding new cases is no big deal anyway. switch(i) { case 0: vec.push_back(new boost::mpl::at >::type); break; case 1: vec.push_back(new boost::mpl::at >::type); break; .... Given its prepetitive nature you could use boost preprocessor library to generate this switch...
-delfin