Continuing my journey into the world of variadic templates, I encountered another problem.

Assuming the following template class:

template < typename T >
struct foo 
{
    //default implementation
};

it is possible to partially specialize it for variadic template instantiations like this:

template < template < typename ... > class T, typename ...Args >
struct foo< T< Args... > >
{
    //specialized implementation
};

With this, foo< int > will correspond to the default implementation and foo< std::tuple< int, char > > to the specialized implementation.

However, things become more complicated when using several template parameters. For example, if we have the following template class

template < typename T, typename U >
struct bar {};

and we want to partially specialize it as we did for foo, we cannot do

template < template < typename ... > class T, typename ...TArgs,
           template < typename ... > class U, typename ...UArgs >
struct bar< T< TArgs... >, U< UArgs... > > {};

//This would correspond to the specialized version with
//T=std::tuple,
//TArgs=int,char
//U=std::tuple,
//UArgs=float
bar< std::tuple< int, char >, std::tuple< float > > b;

Indeed, if I am correct, we can only have one template parameter pack and it must be positioned at the end of the parameter list. I understand why this is mandatory in template declarations, but for certain partial template specialization (like the example above), this should not be an issue.

Is it possible to achieve partial template specialization with multiple template parameter packs?


Edit: Now I feel silly...the code I gave abov

Edit
Report