Can a variation pattern match an invariant pattern?

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. is talking:

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’

This basically means that the variational type pattern is std::tuplenot a valid template argument for Tin apply.

Is this a GCC bug or is the standard one setting this behavior?

+4
source share
3 answers

Someone will correct me if I am wrong, but it seems that this is correct from this quote:

3 - ( P), -- - [FI 11] ( A) P

A ( ) P .

, , , , .

Ps (14.5.3), A P

, , , ,

template<template<class> class T,class U>                                       
struct apply                                                                       
{                                                                                  
         typedef T<U> type;                                                        
};                                                                                 

template<class T> using tuple_type  = std::tuple<T>;
typedef apply<tuple_type,int>::type tuple_of_one_int;                          

++ 11 .

template <class ... Types> class C { /βˆ— ... βˆ—/ };

template<template<class> class P> class X { /βˆ— ... βˆ—/ };

X<C> xc; //ill-formed: a template parameter pack does not match a template parameter  

, C std::tuple.

+4

, ( 14.3.3/2):

...
template <class ... Types> class C { /βˆ— ... βˆ—/ };

template<template<class> class P> class X { /βˆ— ... βˆ—/ };
...
X<C> xc; // ill-formed: a template parameter pack does not match a template parameter
...
+3

:

template<template<class...> class T,class U>
struct apply
{
     typedef T<U> type;
};

typedef apply<std::tuple,int>::type tuple_of_one_int;
typedef apply<std::vector,int>::type vector_of_int;
0

All Articles