Title
Unnamed scoped enumerations
Status
nad
Section
9.7.1 [dcl.enum]
Submitter
John Spicer

Created on 2011-05-12.00:00:00 last changed 140 months ago

Messages

Date: 2011-08-15.00:00:00

Rationale (August, 2011):

The use of typedef names for linkage purposes is intended for C compatibility and should not be extended to features that are not part of the C subset of C++.

Date: 2022-11-20.07:54:16

The text of 9.7.1 [dcl.enum] paragraph 2 explicitly forbids unnamed scoped enumerations:

The optional identifier shall not be omitted in the declaration of a scoped enumeration.

There does not appear to be a good rationale for this restriction since a typedef name can be used to name the enumerators. It is also inconsistent with similar constructs. For example,

    typedef enum class { e } E;
    E x = E::e;

is ill-formed, but

    typedef struct { enum { s }; } S;
    int y = S::s;

is well-formed.

History
Date User Action Args
2012-09-24 00:00:00adminsetmessages: + msg4024
2011-05-12 00:00:00admincreate