g ++ 3.4.5 accepts this code:
template <typename T> struct A { static const char* const str; }; struct B {}; typedef A<B> C; template<> const char* const C::str = "B";
But I'm not sure if this is really legal C ++ 03. In particular,
[14.7p3] In an explicit specialization declaration for a class template, class template member, or class member template, a class name that is explicitly specialized must be the template identifier.
Does this mean that the non-typedef version should be used at the end of this example? Or am I misinterpreting something?
Edit: additional evidence: 403 defects report assumes that it is incorrect to indicate the type (in this context, the argument type is the expression of the function call) is the identifier of the template, because the template identifier has a syntactical value, and not semantic. Later drafts of the Standard used the "template template specification" instead of the "template-id" in 3.4.2.
This supports the argument that although A<B> and C are of the same type (and have the same or almost identical meaning), A<B> is the identifier of the template, and C not, because the term template -id refers to the syntax content as a sequence of tokens, not the meaning of these tokens.
source share