Boost logo

Boost Users :

From: Scott Meyers (usenet_at_[hidden])
Date: 2007-03-27 20:57:45


Given some base class,

   class Base { virtual ~Base(){} };

I want to be able to implement this:

   template<typename Seq>
   const Base& createObject()
   {
     // return an object that inherits from Base and every type in Seq
   }

The problem is how to create the type of object I want.

mpl::inherit is almost what I need, but it takes as template parameters each
type to inherit from, and I don't have discrete types, I have a sequence of
types. mpl::inherit_linearly takes a sequence and would work for my purposes
(which is to create an object that I can later check via dynamic_cast to see if
it inherits from a given type), but it works only with forward sequences, and
I'll typically have an mpl::set. I could copy the contents of Seq into an
mpl::vector and go from there, but that seems kind of gross.

Is there a good way to solve this problem that I am overlooking?

Thanks,

Scott


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