[Voted into the WP at the March, 2011 meeting as part of paper N3262.]
Proposed resolution (November, 2010) [SUPERSEDED]: Change Clause 13 [temp] paragraph 1 as follows: ...The declaration in a template-declaration shall declare or define a function or class, or define a member function, a member class, a member
enumeration, or a static data member of a class template or of a
class nested within a class template, or ... Change 13.7.2 [temp.class] paragraph 3 as follows: Add a new section following 13.7.2.5 [temp.static]: 14.5.1.4 Enumeration members of class templates
[temp.mem.enum] An enumeration member of a class template may be defined outside
the class template definition. [Example: —end example] Change 13.9 [temp.spec] paragraph 2 as follows: Change 13.9.2 [temp.inst] paragraph 1 as follows: Change 13.9.4 [temp.expl.spec] paragraph 1 as follows: An explicit specialization of any of the following: function template class template member function of a class template static data member of a class template member class of a class template member enumeration of a class template member class template of a class or class template member function template of a class or class template can be declared by a declaration introduced by
template<> ... Change 13.9.4 [temp.expl.spec] paragraph 4 as follows: Add the indicated text to the example in 13.9 [temp.spec] paragraph 6:
Change 13.9.4 [temp.expl.spec] paragraph 7 as follows:
When a member function, a member class, a member
enumeration, a static data member or a member template of a
class template is defined outside of the class template definition...
template<class T> struct A {
enum E: T;
};
A<int> a;
template<class T> enum A<T>::E: T { e1, e2 };
A<int>::E e = A<int>::e1;
A function instantiated from a function template is called an
instantiated function. A class instantiated from a class template is
called an instantiated class. A member function, a member class,
a member enumeration, or a static data member of a class
template instantiated from the member definition of the class template
is called, respectively, an instantiated member function, member
class, member enumeration, or static data member. A member
function...
...The implicit instantiation of a class template specialization
causes the implicit instantiation of the declarations, but not of the
definitions or default arguments, of the class member functions,
member classes, scoped member enumerations, static data
members and member templates; and it causes the implicit instantiation
of the definitions of unscoped member enumerations and member
anonymous unions. Unless a member...
A member function, a member class, a member enumeration, or
a static data member of a class template may be explicitly specialized
for a class specialization that is implicitly instantiated...
template<> void sort<>(Array(<char*>& v); // OK: sort<char*> not yet used
template<class T> struct A {
enum E: T;
enum class S: T;
};
template<> enum A<int>::E: int { eint }; // OK
template<> enum class A<int>::S: int { sint }; // OK
template<class T> enum A<T>::E: T { eT };
template<class T> enum class A<T>::S: T { sT };
template<> enum A<char>::E: int { echar }; // ill-formed, A<char>::E was instantiated when A<char> was instantiated
template<> enum class A<char>::S: int { schar }; // OK
The placement of explicit specialization declarations for function
templates, class templates, member functions of class templates,
static data members of class templates, member classes of class
templates, member enumerations of class templates, member
class templates of class templates, member function templates...
Presumably an out-of-class definition for an opaque enumeration
member of a class template is intended to be allowed; however, the
current wording of 13.7.2 [temp.class] provides only for
out-of-class definitions of member functions, member classes,
static data members, and member templates, not for opaque
enumerations.