Created on 2016-03-02.00:00:00 last changed 48 months ago
Proposed resolution (November, 2017)
Change 11.4.5 [class.ctor] paragraph 1 as follows:
...and the id-expression has one of the following forms:
in a member-declaration that belongs to the member-specification of a class or class template but is not a friend declaration (11.8.4 [class.friend]), the id-expression is the injected-class-name ( Clause 11 [class]) of the immediately-enclosing
class;entity or
in a member-declaration that belongs to the member-specification of a class template but is not a friend declaration, the id-expression is a class-name that names the current instantiation (13.8.3.2 [temp.dep.type]) of the immediately-enclosing class template; orin a declaration at namespace scope or in a friend declaration, the id-expression is a qualified-id that names a constructor (6.5.5.2 [class.qual]).
Change 11.4.7 [class.dtor] paragraph 1 as follows:
...and the id-expression has one of the following forms:
in a member-declaration that belongs to the member-specification of a class or class template but is not a friend declaration (11.8.4 [class.friend]), the id-expression is ~class-name and the class-name is the injected-class-name (Clause 11 [class]) of the immediately-enclosing
class;entity or
in a member-declaration that belongs to the member-specification of a class template but is not a friend declaration, the id-expression is ~class-name and the class-name names the current instantiation (13.8.3.2 [temp.dep.type]) of the immediately-enclosing class template; orin a declaration at namespace scope or in a friend declaration, the id-expression is nested-name-specifier ~class-name and the class-name names the same class as the nested-name-specifier.
Add the following as a new paragraph in C.3 [diff.cpp17]:
C.5.x Clause 15: Special member functions [diff.cpp17.special]
Affected subclauses: 11.4.5 [class.ctor], 11.4.7 [class.dtor]
Change: A simple-template-id is no longer valid as the declarator-id of a constructor or destructor.
Rationale: Remove potentially error-prone option for redundancy.
Effect on original feature: Valid C++ 2017 code may fail to compile.template<class T> struct A { A<T>(); // error: simple-template-id not allowed for constructor A(int); // OK, injected-class-name used ~A<T>(); // error: simple-template-id not allowed for destructor };
(Note that this resolution is a change for C++20, NOT a defect report against C++17 and earlier versions.)
[Accepted at the March, 2018 (Jacksonville) meeting.]
Bullet 1.2 of 11.4.5 [class.ctor], describing declarator forms that are considered to declare a constructor, says:
...and the id-expression has one of the following forms:
...
in a member-declaration that belongs to the member-specification of a class template but is not a friend declaration, the id-expression is a class-name that names the current instantiation (13.8.3.2 [temp.dep.type]) of the immediately-enclosing class template; or
...
The term class-name includes simple-template-id. It is not clear that allowing a constructor declaration of the form
template<class T> struct X {
X<T>(T); // constructor
};
is useful or helpful.
History | |||
---|---|---|---|
Date | User | Action | Args |
2020-12-15 00:00:00 | admin | set | status: accepted -> cd5 |
2018-04-11 00:00:00 | admin | set | status: tentatively ready -> accepted |
2018-02-27 00:00:00 | admin | set | messages: + msg5867 |
2018-02-27 00:00:00 | admin | set | status: open -> tentatively ready |
2016-03-02 00:00:00 | admin | create |