<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 874</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="874"></A><H4>874.
  
Class-scope definitions of enumeration types
</H4>
<B>Section: </B>11.4&#160; [<A href="https://wg21.link/class.mem">class.mem</A>]
 &#160;&#160;&#160;

 <B>Status: </B>CD2
 &#160;&#160;&#160;

 <B>Submitter: </B>Daniel Kr&#252;gler
 &#160;&#160;&#160;

 <B>Date: </B>16 April, 2009<BR>


<P>[Voted into WP at October, 2009 meeting.]</P>



<P>According to 11.4 [<A href="https://wg21.link/class.mem#1">class.mem</A>] paragraph 1,</P>

<BLOCKQUOTE>

The enumerators of an enumeration (9.8.1 [<A href="https://wg21.link/dcl.enum">dcl.enum</A>]) defined
in the class are members of the class... A member shall not be
declared twice in the <I>member-specification</I>, except
that a nested class or member class template can be declared and then
later defined.

</BLOCKQUOTE>

<P>The enumerators of a scoped enumeration are not members of the
containing class; the wording should be revised to apply only to
unscoped enumerations. </P>

<P>The second part of the cited wording from 11.4 [<A href="https://wg21.link/class.mem">class.mem</A>]
prohibits constructs like:</P>

<PRE>
    class C {
      public:
        enum E: int;
      private:
        enum E: int { e0 };
    };
</PRE>

<P>which might be useful in making the enumeration type, but not its
enumerators, accessible.</P>

<P><B>Notes from the July, 2009 meeting:</B></P>

<P>According to 11.8.2 [<A href="https://wg21.link/class.access.spec#4">class.access.spec</A>] paragraph 4, the access must
be the same for all declarations of a class member.  The suggested
usage given above violates that requirement: the second declaration of
<TT>E</TT> declares the enumeration itself, not just the enumerators,
to be private.  The CWG did not feel that the utility of the suggested
feature warranted the complexity of an exception to the general rule.</P>

<P><B>Proposed resolution (July, 2009):</B></P>

<OL>
<LI><P>Change 11.4 [<A href="https://wg21.link/class.mem#1">class.mem</A>] paragraph 1 as follows:</P></LI>

<BLOCKQUOTE>

...The enumerators of an <INS>unscoped</INS> enumeration (9.8.1 [<A href="https://wg21.link/dcl.enum">dcl.enum</A>])
defined in the class are members of the class... A member shall not be
declared twice in the <I>member-specification</I>, except that a
nested class or member class template can be declared and then later
defined<INS>, and except that an enumeration can be first introduced with
an <I>opaque-enum-declaration</I> and then later be redeclared with an
<I>enum-specifier</I></INS>.

</BLOCKQUOTE>

<LI><P>Change the example in 11.8.2 [<A href="https://wg21.link/class.access.spec#4">class.access.spec</A>] paragraph 4
as follows:</P></LI>

<P>When a member is redeclared within its class definition, the access
specified at its redeclaration shall be the same as at its initial
declaration. [<I>Example:</I>
</P>

<PRE>
  struct S {
    class A;
<INS>    enum E : int;</INS>
  private:
    class A { };          //<SPAN CLASS="cmnt"> error: cannot change access</SPAN>
<INS>    enum E : int { e0 };  //<SPAN CLASS="cmnt"> error: cannot change access</SPAN></INS>
  };
</PRE>

<P>&#8212;<I>end example</I>]</P>

</OL>

<BR><BR>
</BODY>
</HTML>
