Can explicit specialization outside namespace use qualified name?
9.3.4 [dcl.meaning]
Steve Adamczyk

Created on 2002-08-23.00:00:00 last changed 143 months ago


Date: 2010-03-15.00:00:00

[Voted into WP at March, 2010 meeting as document N3064.]

Date: 2010-02-15.00:00:00

Proposed resolution (February, 2010):

  1. Change 9.3.4 [dcl.meaning] as follows:

  2. ...A declarator-id shall not be qualified except for the definition of a member function (11.4.2 [class.mfct]) or static data member (11.4.9 [class.static]) outside of its class, the definition or explicit instantiation of a function or variable member of a namespace outside of its namespace, or the definition of a previously declared an explicit specialization outside of its namespace, or the declaration of a friend function that is a member of another class or namespace (11.8.4 [class.friend]). When the declarator-id is qualified, the declaration shall refer to a previously declared member of the class or namespace to which the qualifier refers (or of an inline namespace within that scope (9.8.2 [namespace.def])) or to a specialization thereof, and the member shall not have been introduced by a using-declaration in the scope of the class or namespace nominated by the nested-name-specifier of the declarator-id. [Note:...
  3. Change 13.9.4 [temp.expl.spec] paragraphs 2-4 as follows:

  4. An explicit specialization shall appear in namespace scope. An explicit specialization whose declarator-id is not qualified shall be declared in the nearest enclosing namespace of the template, or, if the namespace is inline (9.8.2 [namespace.def]), any namespace from its enclosing namespace set. Such a declaration may also be a definition. If the declaration is not a definition, the specialization may be defined later (_N4868_. [namespace.memdef]).

    A declaration of a function template or class template being explicitly specialized shall be in scope at the point of precede the declaration of an the explicit specialization. [Note: a declaration, but not a definition of the template is required. —end note] The definition of a class or class template shall be in scope at the point of precede the declaration of an explicit specialization for a member template of the class or class template. [Example: ... —end example]

    A member function, a member class or a static data member of a class template may be explicitly specialized for a class specialization that is implicitly instantiated; in this case, the definition of the class template shall be in scope at the point of declaration of preced the explicit specialization for the member of the class template. If such an explicit specialization for the member of a class template names an implicitly-declared special member function (Clause 11.4.4 [special]), the program is ill-formed.

Date: 2002-10-15.00:00:00

Notes from October 2002 meeting:

There was agreement that we wanted to allow this.

Date: 2002-08-23.00:00:00

This case is nonstandard by 9.3.4 [dcl.meaning] paragraph 1 (there is a requirement that the specialization first be declared within the namespace before being defined outside of the namespace), but probably should be allowed:

  namespace NS1 {
    template<class T>
    class CDoor {
      int mtd() { return 1; }
  template<> int NS1::CDoor<char>::mtd()
    return 0;
Date User Action Args
2010-03-29 00:00:00adminsetmessages: + msg2702
2010-03-29 00:00:00adminsetstatus: review -> cd2
2010-02-16 00:00:00adminsetmessages: + msg2541
2010-02-16 00:00:00adminsetstatus: drafting -> review
2002-11-08 00:00:00adminsetmessages: + msg751
2002-11-08 00:00:00adminsetstatus: open -> drafting
2002-08-23 00:00:00admincreate