|
Boost Users : |
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2007-03-27 23:01:16
On 3/27/07, Scott Meyers <usenet_at_[hidden]> wrote:
> 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.
>
> Thanks,
>
> Scott
I'm probably won't use the correct mpl-isms, but something like
template <typename Seq>
struct inherit_all
{
struct type
:
public virtual first<Seq>::type,
public virtual inherit_all<tail<Seq>::type>::type
{
};
};
assuming first<> and tail<> exist or are easily implementable.
Then
template <typename Seq>
struct Base_and_Seq
:
public virtual Base,
public virtual inherit_all<Seq>::type
{
};
> template<typename Seq>
> const Base& createObject()
> {
> // return an object that inherits from Base and every type in Seq
return new Base_and_Seq<Seq>();
> }
Does any of that work, or at least head in the right direction? Or am
I just recreating what inherit_linearly, etc already does?
Tony
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