Created on 2002-11-08.00:00:00 last changed 196 months ago
[Voted into WP at October 2005 meeting.]
Proposed resolution (October, 2004):
Change 13.8 [temp.res] paragraph 3 as follows:
AWhen a qualified-idthat refers to a type andin which the nested-name-specifier depends on a template-parameter (13.8.3 [temp.dep]) is intended to refer to a type, it shall be prefixed by the keyword typenameto indicate that the qualified-id denotes a type, forming a typename-specifier. If the qualified-id in a typename-specifier does not denote a type, the program is ill-formed.
Change 13.8 [temp.res] paragraph 5 as follows:
The keyword typename shall only be used in template declarations and definitions, including in the return type of a function template or member function template, in the return type for the definition of a member function of a class template or of a class nested within a class template, and in the type-specifier for the definition of a static member of a class template or of a class nested within a class template. The keyword typename shall be applied only to qualified names, but those names need not be dependent. The keyword typename shall be used only in contexts in which dependent names can be used. This includes template declarations and definitions but excludes explicit specialization declarations and explicit instantiation declarations.A qualified name used as the name in a mem-initializer-id, a base-specifier, or an elaborated-type-specifier is implicitly assumed to name a type, without the use of the typename keyword. [Note: the typename keyword is not permitted by the syntax of these constructs. —end note]
Notes from October 2003 meeting:
We considered whether typename should be allowed in more places, and decided we only wanted to allow it in qualified names (for now at least).
Core issue 254 changed elaborated-type-specifier to typename-specifier. It also changed 13.8 [temp.res] paragraph 5, which this proposed resolution deletes.
See also issue 468.
Proposed resolution (April 2003):
Replace the text at the start of 13.8 [temp.res] paragraph 3:
A qualified-id that refers to a type and in which the nested-name-specifier depends on a template-parameter (13.8.3 [temp.dep]) shall be prefixed by the keyword typename to indicate that the qualified-id denotes a type, forming an elaborated-type-specifier (9.2.9.5 [dcl.type.elab]).
With:
The keyword typename can only be applied to a qualified-id. A qualified-id that refers to a type and in which the nested-name-specifier depends on a template-parameter (13.8.3 [temp.dep]) shall be prefixed by the keyword typename to indicate that the qualified-id denotes a type, forming an elaborated-type-specifier (9.2.9.5 [dcl.type.elab]). If a qualified-id which has been prefixed by the keyword typename does not denote a type the program is ill-formed. [ Note: The keyword is only required on a qualified-id within a template declaration or definition in which the nested-name-specifier depends on a template-parameter. ]
Remove 13.8 [temp.res] paragraph 5:
The keyword typename shall only be used in template declarations and definitions, including in the return type of a function template or member function template, in the return type for the definition of a member function of a class template or of a class nested within a class template, and in the type-specifier for the definition of a static member of a class template or of a class nested within a class template. The keyword typename shall be applied only to qualified names, but those names need not be dependent. The keyword typename shall be used only in contexts in which dependent names can be used. This includes template declarations and definitions but excludes explicit specialization declarations and explicit instantiation declarations. The keyword typename is not permitted in a base-specifier or in a mem-initializer; in these contexts a qualified-id that depends on a template-parameter (temp.dep) is implicitly assumed to be a type name.
Note: the claim here that a qualified name preceded by typename forms an elaborated type specifier conflicts with the changes made in issue 254 (see N1376=02-0034), which introduces typename-specifier.
Notes from the April 2003 meeting:
There was unanimity on relaxing this requirement on typename. The question was how much to relax it. Everyone agreed on allowing it on all qualified names, which is an easy fix (no syntax change required). But should it be allowed other places? P.J. Plauger said he'd like to see it allowed anywhere a type name is allowed, and that it could actually be a decades-late assist for the infamous "the ice is thin here" typedef problem noted in K&R I.
P. J. Plauger, among others, has noted that typename is hard to use, because in a given context it's either required or forbidden, and it's often hard to tell which. It would make life easier for programmers if typename could be allowed in places where it is not required, e.g., outside of templates.
History | |||
---|---|---|---|
Date | User | Action | Args |
2008-10-05 00:00:00 | admin | set | status: wp -> cd1 |
2006-04-22 00:00:00 | admin | set | status: dr -> wp |
2005-10-22 00:00:00 | admin | set | messages: + msg1284 |
2005-10-22 00:00:00 | admin | set | status: ready -> dr |
2005-05-01 00:00:00 | admin | set | status: review -> ready |
2004-11-07 00:00:00 | admin | set | messages: + msg1069 |
2004-11-07 00:00:00 | admin | set | status: drafting -> review |
2003-11-15 00:00:00 | admin | set | messages: + msg937 |
2003-11-15 00:00:00 | admin | set | status: review -> drafting |
2003-04-25 00:00:00 | admin | set | messages: + msg832 |
2003-04-25 00:00:00 | admin | set | messages: + msg831 |
2003-04-25 00:00:00 | admin | set | status: open -> review |
2002-11-08 00:00:00 | admin | create |