Boost logo

Boost :

From: Jody Hagins (jody-boost-011304_at_[hidden])
Date: 2004-08-25 13:35:02


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!


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk