Is this legal C++?
template <typename T, template <typename T> class>
struct S { };
Clang (3.7.1) rejects it, complaining the second T
shadows the first T
. GCC seems not to care about it and I think that's reasonable. I think it is only the number of parameters that matters in a template template parameter.
- http://goo.gl/51bHVG (gcc.godbolt.org)
T
twice? if you want to useT
in the second template you can writetemplate <class T, template <class S=T> class>
– Pentheatemplate <class T, template <class S> class>
? – ClyburnNULL
tonullptr
? – Clyburntemplate <template T, template <class S=T> class C>
, we can replaceC<T>
withC<>
as ifC
was defined with a default template parameter... This can be handy in some cases, but I'm not sure I'll be using it often. Anyways thanks so much. – Clyburn