Created on 2023-01-11.00:00:00 last changed 11 months ago
Proposed resolution (approved by CWG 2023-03-03):
Change in 9.3.4.7 [dcl.fct.default] paragraph 6 as follows:
Except for member functions ofclass templatestemplated classes, the default arguments in a member function definition that appears outside of the class definition are added to the set of default arguments provided by the member function declaration in the class definition; the program is ill-formed if a default constructor (11.4.5.2 [class.default.ctor]), copy or move constructor (11.4.5.3 [class.copy.ctor]), or copy or move assignment operator (11.4.6 [class.copy.assign]) is so declared. Default arguments for a member function of a templated classtemplateshall be specified on the initial declaration of the member function within the templated classtemplate.
[Accepted as a DR at the June, 2023 meeting.]
Subclause 9.3.4.7 [dcl.fct.default] paragraph 6 specifies:
Except for member functions of class templates, the default arguments in a member function definition that appears outside of the class definition are added to the set of default arguments provided by the member function declaration in the class definition; the program is ill-formed if a default constructor (11.4.5.2 [class.default.ctor]), copy or move constructor (11.4.5.3 [class.copy.ctor]), or copy or move assignment operator (11.4.6 [class.copy.assign]) is so declared. Default arguments for a member function of a class template shall be specified on the initial declaration of the member function within the class template.
That rule appears to allow adding default arguments for member functions of classes that are nested within class templates, for example:
template<class> struct A { struct B { void c(int); }; }; template<class T> void A<T>::B::c(int = 0) {}
MSVC accepts; gcc and clang reject.
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-12-19 10:15:28 | admin | set | status: dr -> drwp |
2023-07-16 13:00:43 | admin | set | status: ready -> dr |
2023-03-03 21:04:52 | admin | set | status: open -> ready |
2023-01-15 11:51:48 | admin | set | messages: + msg7136 |
2023-01-11 00:00:00 | admin | create |