Created on 2001-07-24.00:00:00 last changed 162 months ago
[Voted into WP at the October, 2006 meeting.]
Proposed resolution (April, 2006):
As specified in document J16/05-0156 = WG21 N1896, except that:
In change 9 (_N4868_.6.5.6 [basic.lookup.classref]), omit the change from “entire postfix-expression” to “nested-name-specifier.”
In change a (184.108.40.206 [class.qual] paragraph 1, third bullet), omit the change from “entire postfix-expression” to “qualified-id.”
In change b (220.127.116.11 [namespace.qual] paragraph 1), omit the change from “entire postfix-expression” to “qualified-id.”
(Some of these omitted changes are addressed by issue 562.)
(This resolution also resolves issue 534.)
Notes from the April, 2005 meeting:
The CWG suggested a new approach to resolving this issue: the existing term template-id will be renamed to class-template-id, the term template-id will be defined to include operator functions with template arguments, and any current uses of template-id (such as in the definition of elaborated-type-specifier) where an operator function is not appropriate will be changed to refer to class-template-id.
Notes from October 2003 meeting:
We reviewed Clark Nelson's N1490. Clark will revise it and introduce a new syntax term for an identifier or the name of an operator function.
Notes from April 2003 meeting:
We felt that the operator functions should not be special-cased. They should be treated like any other name.
Clark Nelson has provided the changes in N1490=03-0073.
Notes from 4/02 meeting:
If the change is made as a syntax change, we'll need a semantic restriction to avoid operator+<int> as a class. Clark Nelson will work on a compromise proposal -- not the minimal change to the syntax proposed, not the maximal change either.
Clark Nelson (April 2003):
The proposed solution (adding operator-function-id as an alternative for template-name) would have a large impact on the language described by the grammar. Specifically, for example, operator+<int> would become a syntactically valid class-name.
On the other hand, a change with (I believe) exactly the desired effect on the language accepted, would be to modify operator-function-id itself:
(Steve Adamczyk: this change was already made by issue 38 and is in TC1.)
Then there is the first sentence of 13.3 [temp.names] paragraph 3:
After name lookup (6.5 [basic.lookup]) finds that a name is a template-name, if this name is followed by a <, the < is always taken as the beginning of a template-argument-list and never as a name followed by the less-than operator.
This description seems to be adequate for names of class templates. As far as I can tell, the only ambiguity it resolves is from something that starts with new X <, in the scope of a class template X. But as far as I can tell is already inadequate for names of function templates, and is even worse for operator function templates.
Probably < should always be interpreted as introducing a template-argument-list if any member of the overload set is a function template. After all, function pointers are very rarely compared for ordering, and it's not clear what other rule might be workable.
I'm inclined to propose the simplest rule possible for operator-function-ids: if one is followed by <, then what follows is interpreted as a template-argument-list, unconditionally. Of course, if no template for that operator has been declared, then there's an error.
Also, note that if the operator in question is < or <<, it is possible to run into a problem similar to the famous >> nested template argument list closing delimiter problem. However, since in this case (at least) one of the < characters has a radically different interpretation than the other, and for other reasons as well, this is unlikely to be nearly as much of a practical problem as the >> problem.
The grammar for a template-name is:
That's not right; consider:
template <class T> T operator+(const T&, const T&); template <> S operator+<S>(const S&, const S&);
This is ill-formed according to the standard, since operator+ is not a template-name.
I think the right rule is
John Spicer adds that there's some question about whether conversion functions should be included, as they cannot have template argument lists.
|2008-10-05 00:00:00||admin||set||status: wp -> cd1|
|2007-05-06 00:00:00||admin||set||status: dr -> wp|
|2006-11-05 00:00:00||admin||set||messages: + msg1442|
|2006-11-05 00:00:00||admin||set||status: ready -> dr|
|2006-04-22 00:00:00||admin||set||status: review -> ready|
|2005-10-22 00:00:00||admin||set||messages: + msg1247|
|2005-10-22 00:00:00||admin||set||status: drafting -> review|
|2005-05-01 00:00:00||admin||set||messages: + msg1165|
|2004-04-09 00:00:00||admin||set||status: review -> drafting|
|2003-11-15 00:00:00||admin||set||messages: + msg928|
|2003-09-19 00:00:00||admin||set||status: drafting -> review|
|2003-04-25 00:00:00||admin||set||messages: + msg841|
|2002-05-10 00:00:00||admin||set||messages: + msg643|
|2001-11-09 00:00:00||admin||set||status: open -> drafting|