I have code:
#include
template class>
struct Foo
{
enum { n = 77 };
};
template
Clang is wrong to reject the partial specialization. To know how to interpret the errormessage, you need to understand what clang diagnoses. It means to diagnose a partial specialization whose arguments match exactly the implicit argument list of the primary class template (<param1, param2, ... , paramN>
).
However the argument lists are differently so clang shall not diagnose it. In particular this has nothing to do wheter the partial specialization matches more or less arguments. Consider
template<typename A, typename B> class C;
template<typename B, typename A> class C<A, B> {};
The partial specialization here matches everything and not more that the primary template would match. And the argument lists of both templates are different so this partial specialization is valid, just like you'rs.
`template<template<typename, typename...> class C>
is no more specialized than
template<template<typename...> class>
Both of them takes a list of unknown type parameters. it is just that the former takes one member of this list as a different parameter. It contains no additional info about the type such that the compiler should select one over the other.
In the typical usage of variadic templates this specialization is generated in terms of parameter count. Thinking about the variadic templates as recursive functions during runtime, you should just supply the terminating condition (as a class taking only one unknown type).
Clang is very keen on diagnostics so I think it is catching the abnormality and rightfully giving errors.
GCC's being able to compile it is strange. Maybe because you are explicitly specifying which templates to use in struct A
and struct B
seperately, gcc was able to catch that and suppress the abnormality.