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

2024-11-11


2692. Static and explicit object member functions with the same parameter-type-lists

Section: 12.2.2.2.1  [over.match.call.general]     Status: C++23     Submitter: Matthew House     Date: 2023-01-16     Liaison: EWG

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

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

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.