Title
Out-of-class definitions of explicit object member functions
Status
drwp
Section
9.3.4.6 [dcl.fct]
Submitter
Krystian Stasiowski

Created on 2024-01-28.00:00:00 last changed 5 months ago

Messages

Date: 2024-02-16.23:23:05

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:
  • a member-declarator that declares declaration 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]).
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.
Date: 2024-03-15.00:00:00

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

The function-definition at #1 is neither of the two allowed options.

Similar concerns arise for explicit instantiations and explicit specializations.

History
Date User Action Args
2024-07-20 13:52:34adminsetstatus: dr -> drwp
2024-04-05 21:43:46adminsetstatus: ready -> dr
2024-03-20 14:10:31adminsetstatus: tentatively ready -> ready
2024-02-16 23:23:05adminsetmessages: + msg7605
2024-02-16 23:23:05adminsetstatus: open -> tentatively ready
2024-01-28 00:00:00admincreate