Reputation: 25613
If I derive from one or more classes I can inherit the constructors with the using
declaration.
Example:
struct A
{
A(int){}
A(){}
};
struct B
{
B(char){}
B(){}
};
struct All: public A,public B
{
using A::A;
using B::B;
};
If I want do the same within a template class, where the base classes are given by a variadic template parameter, how can I use the using declaration?
Example ( The same as above, but using a template class to inherit )
template < typename ... P>
struct All2: public P...
{
using P...::P...; ??? is there a syntax available to "use" the constructors from all base classes?
};
And the main can be something like:
int main()
{
All all1(1);
All2<A,B> all2(2);
}
Upvotes: 1
Views: 40
Reputation: 38518
template < typename ... P>
struct All2: public P...
{
using P::P...;
};
Upvotes: 2