Специализация вариативного параметра шаблона шаблона на минимальном количестве аргументов:допустима или нет?

У меня есть код:

#include <cstdio>

template<template<typename...> class>
struct Foo 
{ 
    enum { n = 77 };
};

template<template<typename, typename...> class C>
struct Foo<C>
{
    enum { n = 99 }; 
};

template<typename...> struct A { };

template<typename, typename...> struct B { };

int main(int, char**)
{
    printf("%d\n", Foo<A>::n);
    printf("%d\n", Foo<B>::n);
}

Идея состоит в том, что template<typename, typename...> classявляется подмножеством template<typename...> class, поэтому на нем можно было бы специализироваться. Но это довольно эзотерично, так что, возможно, нет. Давайте попробуем.

GCC 4.7 говорит:

$ g++ -std=c++11 test157.cpp 

Он скомпилирован!

Запуск:

$./a.out 
77
99

Работает!

Clang 3.1 говорит:

$ clang++ -std=c++11 test157.cpp
test157.cpp:10:8: error: class template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list
struct Foo<C>
       ^  ~~~
test157.cpp:9:10: error: too many template parameters in template template parameter redeclaration
template<template<typename, typename...> class C>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test157.cpp:3:10: note: previous template template parameter is here
template<template<typename...> class>
         ^~~~~~~~~~~~~~~~~~~~~
2 errors generated.

Кто прав?

16
задан glaebhoerl 19 March 2012 в 14:45
поделиться