[mpl] A simple question about using lists/vectors

I apologize in advance for this seemingly simple question, but I am having a hard time finding a simple solution in the online docs (I am in line for the MPL book, though ;-) Lets say I have some code like this... template <class A, class B> class Bar { public: Bar() { foo.template do_something<A>(); foo.template do_something<B>(); } private: Foo foo; }; Bar<Type1, Type2> bar; but I want to create a Bar with an arbitrary number of classes... Bar<boost::mpl::vector<Type1, Type2, Type3, ..., TypeN> > bar; and in the ctor, I want to call the do_something template method for each type, so that it expands to something like... Bar() { foo.template do_something<Type1>(); foo.template do_something<Type2>(); foo.template do_something<Type3>(); ... foo.template do_something<TypeN>(); } Any help would be appreciated. Thanks!

"Jody Hagins" <jody-boost-011304@atdesk.com> wrote
and in the ctor, I want to call the do_something template method for each type, so that it expands to something like...
Bar() { foo.template do_something<Type1>(); foo.template do_something<Type2>(); foo.template do_something<Type3>(); ... foo.template do_something<TypeN>(); }
Use mpl::for_each<vector>(functor), where vector is any MPL sequence, and functor has a templated function call operator. Regards, Arkadiy
participants (2)
-
Arkadiy Vertleyb
-
Jody Hagins