Created on 2003-08-29.00:00:00 last changed 196 months ago
[Voted into WP at March 2004 meeting.]
Proposed Resolution (October 2003):
The answer to question 1 above is No and no change is required.
For question 1, change 6.4.7 [basic.scope.class] paragraph 1 rule 1 to:
1) The potential scope of a name declared in a class consists not only of the declarative region following the name's point of declarationdeclarator, but also of all function bodies, default arguments, and constructor ctor-initializers in that class (including such things in nested classes). The point of declaration of an injected-class-name (Clause 11 [class]) is immediately following the opening brace of the class definition.
(Note that this change overlaps a change in issue 417.)
Also change 6.4.2 [basic.scope.pdecl] by adding a new paragraph 8 for the injected-class-name case:
The point of declaration for an injected-class-name (Clause 11 [class]) is immediately following the opening brace of the class definition.
Alternatively this paragraph could be added after paragraph 5 and before the two note paragraphs (i.e. it would become paragraph 5a).
Notes from October 2003 meeting:
We agree with John Spicer's suggested answers above.
Consider the following example (inspired by a question from comp.lang.c++.moderated):
template<typename> struct B {}; template<typename T> struct D: B<D> {};
Most (all?) compilers reject this code because D is handled as a template name rather than as the injected class name.
Clause 11 [class]/2 says that the injected class name is "inserted into the scope of the class."
6.4.7 [basic.scope.class]/1 seems to be the text intended to describe what "scope of a class" means, but it assumes that every name in that scope was introduced using a "declarator". For an implicit declaration such as the injected-class name it is not clear what that means.
So my questions:
John Spicer: I do not believe the injected class name should be available in the base specifier. I think the semantics of injected class names should be as if a magic declaration were inserted after the opening "{" of the class definition. The injected class name is a member of the class and members don't exist at the point where the base specifiers are scanned.
John Spicer: I believe the 6.4.7 [basic.scope.class] wording should be updated to reflect the fact that not all names come from declarators.
History | |||
---|---|---|---|
Date | User | Action | Args |
2008-10-05 00:00:00 | admin | set | status: wp -> cd1 |
2004-04-09 00:00:00 | admin | set | messages: + msg1000 |
2004-04-09 00:00:00 | admin | set | status: ready -> wp |
2003-11-15 00:00:00 | admin | set | messages: + msg907 |
2003-11-15 00:00:00 | admin | set | messages: + msg906 |
2003-11-15 00:00:00 | admin | set | status: open -> ready |
2003-08-29 00:00:00 | admin | create |