Boost logo

Boost Users :

From: Delfin Rojas (drojas_at_[hidden])
Date: 2006-03-17 18:20:51


> 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<T0, T1, T2, T3> 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<TTypes,
> boost::mpl::int_<0> >::type);
> break;
> case 1:
> vec.push_back(new boost::mpl::at<TTypes,
> boost::mpl::int_<1> >::type);
> break;
> ....
>

Given its prepetitive nature you could use boost preprocessor library to
generate this switch...

-delfin


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net