Created on 2009-04-16.00:00:00 last changed 178 months ago
[Voted into WP at October, 2009 meeting.]
Proposed resolution (July, 2009):
Change 11.4 [class.mem] paragraph 1 as follows:
...The enumerators of an unscoped enumeration (9.7.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.
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:
struct S { class A; enum E : int; private: class A { }; // error: cannot change access enum E : int { e0 }; // error: cannot change access };
—end example]
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.
According to 11.4 [class.mem] paragraph 1,
The enumerators of an enumeration (9.7.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.
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:
class C { public: enum E: int; private: enum E: int { e0 }; };
which might be useful in making the enumeration type, but not its enumerators, accessible.
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 |