1

I use mpl::vector from boost 1.58. I have types:

typedef mpl::vector <base1, base2, base3> types;

If I have a class derived, how can i inherit it from all of these types in this mpl::vector?

Vinay Shukla
  • 1,818
  • 13
  • 41
D. Ermolaev
  • 148
  • 1
  • 6

1 Answers1

2

You may use inherit_linearly.

Example of usage:

class A 
{
public:
   void a() {}
};
class B 
{
public:
   void b() {}
};
class C 
{
public:
   void c() {}
};

typedef boost::mpl::vector<A, B, C> types;


class Derived :
public boost::mpl::inherit_linearly<types, 
boost::mpl::inherit<boost::mpl::_1, boost::mpl::_2> >::type
{
};

int main()
{
   Derived d;
   d.a();
   d.b();
   d.c();
}
ForEveR
  • 55,233
  • 2
  • 119
  • 133