Title
Static and explicit object member functions with the same parameter-type-lists
Status
c++23
Section
12.2.2.2.1 [over.match.call.general]
Submitter
Matthew House

Created on 2023-01-16.00:00:00 last changed 16 months ago

Messages

Date: 2023-02-21.07:34:27

CWG 2023-01-27

Forward to EWG to determine whether such member declarations are considered sufficiently confusing to outweigh concerns of language orthogonality; see plusplus/papers#1455.

Date: 2023-01-27.23:50:39

Suggested resolution:

  1. Change in 6.4.1 [basic.scope.scope] paragraph 3, adding bullets, a follows:

    Two function templates have corresponding signatures if
    • their template-parameter-lists have the same length,
    • their corresponding template-parameters are equivalent,
    • they have equivalent
      • parameter-type-lists or non-object-parameter-type-lists and
      • return types (if any), and,
    • if both are non-static members, they have corresponding object parameters.
  2. Change in 6.4.1 [basic.scope.scope] bullet 4.3.1 as follows:

    • both declare functions with the same parameter-type-list or non-object-parameter-type-list [Footnote: ...], equivalent (13.7.7.2 [temp.over.link]) trailing requires-clauses (if any, except as specified in 13.7.5 [temp.friend]), and, if both are non-static members, they have corresponding object parameters, or
Date: 2023-02-15.00:00:00

[Accepted at the February, 2023 meeting as part of paper P2797R0.]

(Split off from issue 2687.)

Consider:

  struct A {
    static void f(A);
    void f(this A);

    void g();
  };

  void A::g() {
    (&A::f)(A()); // #1
    (&A::f)();    // #2
  }

It is obvious that #2 is ill-formed, but what about #1? One possible answer is to make such declarations conflict.

History
Date User Action Args
2023-07-16 13:00:43adminsetstatus: open -> c++23
2023-07-16 13:00:43adminsetstatus: accepted -> open
2023-02-18 18:43:04adminsetstatus: open -> accepted
2023-01-27 23:50:39adminsetmessages: + msg7155
2023-01-27 23:50:39adminsetmessages: + msg7154
2023-01-16 00:00:00admincreate