This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 113d. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-03-20


1206. Defining opaque enumeration members of class templates

Section: 13.7.2  [temp.class]     Status: C++11     Submitter: Jason Merrill     Date: 2010-10-06

[Voted into the WP at the March, 2011 meeting as part of paper N3262.]

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.

Proposed resolution (November, 2010) [SUPERSEDED]:

  1. Change Clause 13 [temp] paragraph 1 as follows:

  2. ...The declaration in a template-declaration shall

  3. Change 13.7.2 [temp.class] paragraph 3 as follows:

  4. 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...
  5. Add a new section following 13.7.2.5 [temp.static]:

  6. 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:

      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;
    

    end example]

  7. Change 13.9 [temp.spec] paragraph 2 as follows:

  8. 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...
  9. Change 13.9.2 [temp.inst] paragraph 1 as follows:

  10. ...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...
  11. Change 13.9.4 [temp.expl.spec] paragraph 1 as follows:

  12. An explicit specialization of any of the following:

  13. Change 13.9.4 [temp.expl.spec] paragraph 4 as follows:

  14. 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...
  15. Add the indicated text to the example in 13.9 [temp.spec] paragraph 6:

  16.   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
    
  17. Change 13.9.4 [temp.expl.spec] paragraph 7 as follows:

  18. 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...