Consider the following snippet:
template<template<class> class T,class U>
struct apply
{
typedef T<U> type;
};
typedef apply<std::tuple,int>::type tuple_of_one_int; //Should be std::tuple<int>
GCC 4.8.2. says:
type/value mismatch at argument 1 in template parameter list for [...] struct apply
expected a template of type ‘template<class> class T’, got ‘template<class ...> class std::tuple’
Which basically means that a variadic template like std::tuple
is not a valid template argument for T
in apply
.
Is this a GCC bug or does the standard mandates this behaviour?
Someone correct me if I'm wrong but it seems like it's correct from this quote:
A
(the given template) has to match each of it's templates parameters toP
's the template template.From the second part of the section we learn the restriction doesn't apply in the reverse, meaning a template template containing a parameter pack can match anything.
As you probably already knew the way to make it work is
The c++11 standard also has an equivalent example to yours.
The last comment completely describes your situation, class
C
would be the equivalent ofstd::tuple
in this case.