
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
::type); break; case 1: vec.push_back(new boost::mpl::at
::type); break; case 2: vec.push_back(new boost::mpl::at ::type); break; case 3: vec.push_back(new boost::mpl::at ::type); break; } } }; struct Display { void operator() (Tbase* p) { p->display(); } }; struct Clean { void operator() (Tbase* p) { delete p; } }; int main (int argc, char ** argv) { std::vector<int> runtimeVec; runtimeVec.push_back(3); runtimeVec.push_back(0); runtimeVec.push_back(0); std::for_each(runtimeVec.begin(), runtimeVec.end(), Functor()); std::cout << vec.size() << std::endl; std::for_each(vec.begin(), vec.end(), Display()); std::for_each(vec.begin(), vec.end(), Clean()); return 0; }
"François Duranleau"
Chapter 11 of "C++ Template Metaprogramming" shows how to generate the equivalent of a switch statement using the MPL.
I will need to save up some money to get that book. -- François Duranleau LIGUM, Université de Montréal "Conflict may erupt at any time and any place. War is the destiny of which humanity can never wash its hands." - Emperor Dornkirk, in _The Vision of Escaflowne_ --------------------------------------------------------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users