Created on 2016-12-10.00:00:00 last changed 34 months ago
Proposed resolution (November, 2018):
Change 9.2.9.3 [dcl.type.simple] paragraph 2 as follows:
The simple-type-specifier auto is a placeholder for a type to be deduced (9.2.9.7 [dcl.spec.auto]). A type-specifier of the form typenameopt nested-name-specifieropt template-name is a placeholder for a deduced class type (9.2.9.8 [dcl.type.class.deduct]). The template-name shall name a class templatethat is not an injected-class-name. [Note: An injected-class-name is never interpreted as a template-name in contexts where a type-specifier may appear (13.8.2 [temp.local]). —end note] The other simple-type-specifiers specify...
Suggested resolution:
Deleting the wording in question and replacing it with a cross-reference to 13.8.2 [temp.local], which makes it clear that the injected-class-name is a type-name and not a template-name in this context, would seem to address the problem adequately.
[Accepted as a DR at the February, 2019 meeting.]
Paper P0091R3 has the following example:
template<typename T> struct X { template<typename Iter> X(Iter b, Iter e) { /* ... */ } template<typename Iter> auto foo(Iter b, Iter e) { return X(b, e); // X<U> to avoid breaking change } template<typename Iter> auto bar(Iter b, Iter e) { return X<Iter::value_type>(b, e); // Must specify what we want } };
The intent was presumably to avoid breaking existing code, but the new wording in 9.2.9.3 [dcl.type.simple] paragraph 2 appears to make the expression X(b, e) ill-formed:
A type-specifier of the form typenameopt nested-name-specifieropt template-name is a placeholder for a deduced class type (9.2.9.8 [dcl.type.class.deduct]). The template-name shall name a class template that is not an injected-class-name.
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-02-18 07:47:23 | admin | set | messages: + msg6716 |
2020-12-15 00:00:00 | admin | set | messages: + msg6394 |
2020-12-15 00:00:00 | admin | set | status: drafting -> cd5 |
2016-12-10 00:00:00 | admin | create |