In the following example, Abstract
is a class template whose first parameter is a type and the second parameter is another template taking a bool along with any number of args.
template<bool,typename>
struct Default;
template< typename T = void,
template<bool,typename ...> class = Default>
struct Abstract;
template<typename T>
struct Abstract<T>
{};
template<typename T, template<bool> class C>
struct Abstract<T,C> : Abstract<T>
{};
int main()
{}
The outputs from Clang and C++ are the following:
Clang: http://rextester.com/BJSW46677
error: class template partial specialization does not specialize any template argument;
G++ http://rextester.com/MDN65674
OK
So, I decided to go clang-friendly and added a third parameter in Abstract
's declaration.
template< typename T = void,
template<bool,typename ...> class = Default,
typename = void >
struct Abstract;
Now, both Clang and G++ were fine with this. I guess the reason Clang was complaining, was because the specialization did not really specialize anything. But that's not true. It specializes for the number of arguments.
Next, I added another specialization for the template template parameter. The example looks like this:
template<bool,typename>
struct Default;
template< typename T = void,
template<bool,typename ...> class = Default,
typename = void >
struct Abstract;
template<typename T>
struct Abstract<T>
{};
template<typename T, template<bool> class C>
struct Abstract<T,C> : Abstract<T>
{};
template<typename T, template<bool,typename> class G>
struct Abstract<T,G> : Abstract<T>
{};
int main()
{}
The outputs from Clang and C++ are the following:
Clang: http://rextester.com/LJIOC38789
error: redefinition of
Abstract<type-parameter-0-0, C, void>
note: previous definition isstruct Abstract<T,C> : Abstract<T>
G++: http://rextester.com/TSDRZ44717
OK - (didn't need the third parameter in the declaration either)
I don't think that Clang is right here because the third specialization is valid for the template template argument, and the variadic template parameter allows me to specialize for any number of arguments. However, I'm not sure.
Question: Which compiler is the buggy one? Why? It would be really nice to get a quote from the spec and more clarity on the subject.