This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-12-19
[Accepted as a DR at the March, 2024 meeting.]
(From submission #493.)
Consider:
struct A {
void f(this A&);
};
void A::f(this A&) { } // #1
This is accepted by all major implementations. However, 9.3.4.6 [dcl.fct] paragraph 6 specifies:
An explicit-object-parameter-declaration is a parameter-declaration with a this specifier. An explicit-object-parameter-declaration shall appear only as the first parameter-declaration of a parameter-declaration-list of either:A member-declarator with an explicit-object-parameter-declaration shall not include a ref-qualifier or a cv-qualifier-seq and shall not be declared static or virtual.
- a member-declarator that declares a member function (11.4 [class.mem]), or
- a lambda-declarator (7.5.6 [expr.prim.lambda]).
The function-definition at #1 is neither of the two allowed options.
Similar concerns arise for explicit instantiations and explicit specializations.
Proposed resolution (approved by CWG 2024-02-16):
Change in 9.3.4.6 [dcl.fct] paragraph 6 as follows:
An explicit-object-parameter-declaration is a parameter-declaration with a this specifier. An explicit-object-parameter-declaration shall appear only as the first parameter-declaration of a parameter-declaration-list ofeitherone of:A member-declarator with an explicit-object-parameter-declaration shall not include a ref-qualifier or a cv-qualifier-seq and shall not be declared static or virtual.
- a
member-declarator that declaresdeclaration of a member function or member function template (11.4 [class.mem]), or- an explicit instantiation (13.9.3 [temp.explicit]) or explicit specialization (13.9.4 [temp.expl.spec]) of a templated member function, or
- a lambda-declarator (7.5.6 [expr.prim.lambda]).