Title
Defining opaque enumeration members of class templates
Status
c++11
Section
13.7.2 [temp.class]
Submitter
Jason Merrill

Created on 2010-10-06.00:00:00 last changed 123 months ago

Messages

Date: 2011-03-15.00:00:00

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

Date: 2010-11-15.00:00:00

Proposed resolution (November, 2010) [SUPERSEDED]:

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

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

    • ...

  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:

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

  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...
Date: 2010-10-06.00:00:00

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.

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetmessages: + msg3382
2011-04-10 00:00:00adminsetstatus: review -> fdis
2010-11-29 00:00:00adminsetmessages: + msg3101
2010-11-29 00:00:00adminsetstatus: open -> review
2010-10-06 00:00:00admincreate