I am trying to create a class that inherits from several classes (as defined by a variational pattern), and for each class passes the same package of args parameters to the constructor of each class. However, it seems that I cannot unzip both the variational class template and the args parameter package.
I have a class:
template<class... __Policies> class GenericPolicyAdapter : public __Policies...{
With constructor:
template<class... __Args> GenericPolicyAdapter( __Args... args ) : __Policies( args... ){
and test:
GenericPolicyAdapter<T1,T2> generic_policy_adapter( arg1, arg2, arg3 );
gcc crash:
error: type '__Policies' is not a direct base of 'GenericPolicyAdapter<T1,T2>'
where __Policies = T1, T2
To clarify, I try:
GenericPolicyAdapter : public T1, public T2 { public: template<class... __Args> GenericPolicyAdapter( __Args... args ) : T1( args... ), T2( args... ){} };
but with T1 and T2 derived from __Policies
Any ideas? __Policies seems to treat __Policies as a single type, not a list of types. Thanks in advance!
Edit:
I must clarify that I am using gcc / g ++ 4.4.5.
Howard Hinnant's proposal was to make:
template<class... __Args> GenericPolicyAdapter( __Args... args ) : __Policies( args...)... {}
However, with gcc / g ++ 4.4.5, this gives invalid use of pack expansion expression . It's great that this works in OSX / clang, but is there a way to do this in gcc / g ++?