Search code examples
c++inheritancevariadic-templates

Multiple Inheritance of variadic classes


Can I do the below?

template<class D>
class A {};

template<class... Ds>
class B : public A<Ds>... {};

I am expecting the behaviour:

template<class D1, class D2>
class B : public A<D1>, public A<D2> {};

Solution

  • Can I do the below?

    Yes.

    Inheriting from the class template is perfectly ok, given that you provide the necessary template parameters, which you've done.