- Title
- Class-scope definitions of enumeration types
- Status
- cd2
- Section
- 11.4 [class.mem]
- Submitter
- Daniel Krügler
Created on 2009-04-16.00:00:00 last changed 199 months ago
Messages
Date: 2009-10-15.00:00:00
[Voted into WP at October, 2009 meeting.]
Date: 2009-07-15.00:00:00
Proposed resolution (July, 2009): Change 11.4 [class.mem] paragraph 1 as follows: Change the example in 11.8.2 [class.access.spec] paragraph 4
as follows: When a member is redeclared within its class definition, the access
specified at its redeclaration shall be the same as at its initial
declaration. [Example:
—end example]
...The enumerators of an unscoped enumeration (9.8.1 [dcl.enum])
defined in the class are members of the class... A member shall not be
declared twice in the member-specification, except that a
nested class or member class template can be declared and then later
defined, and except that an enumeration can be first introduced with
an opaque-enum-declaration and then later be redeclared with an
enum-specifier.
struct S {
class A;
enum E : int;
private:
class A { }; // error: cannot change access
enum E : int { e0 }; // error: cannot change access
};
Date: 2009-07-15.00:00:00
Notes from the July, 2009 meeting: According to 11.8.2 [class.access.spec] 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
E 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.
Date: 2009-04-16.00:00:00
According to 11.4 [class.mem] paragraph 1, The enumerators of a scoped enumeration are not members of the
containing class; the wording should be revised to apply only to
unscoped enumerations. The second part of the cited wording from 11.4 [class.mem]
prohibits constructs like: which might be useful in making the enumeration type, but not its
enumerators, accessible.
The enumerators of an enumeration (9.8.1 [dcl.enum]) defined
in the class are members of the class... A member shall not be
declared twice in the member-specification, except
that a nested class or member class template can be declared and then
later defined.
class C {
public:
enum E: int;
private:
enum E: int { e0 };
};
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2010-03-29 00:00:00 | admin | set | status: dr -> cd2 |
| 2009-11-08 00:00:00 | admin | set | messages: + msg2465 |
| 2009-11-08 00:00:00 | admin | set | status: ready -> dr |
| 2009-08-03 00:00:00 | admin | set | messages: + msg2171 |
| 2009-08-03 00:00:00 | admin | set | messages: + msg2170 |
| 2009-08-03 00:00:00 | admin | set | status: open -> ready |
| 2009-04-16 00:00:00 | admin | create | |