CWG Issue 2846 (original) (raw)

This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 117a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-04-13


2846. Out-of-class definitions of explicit object member functions

Section: 9.3.4.6 [dcl.fct]Status: DRWPSubmitter: Krystian StasiowskiDate: 2024-01-28

[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:

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_ of either one of: