Title
Partial ordering and explicit object parameters
Status
review
Section
13.7.7.3 [temp.func.order]
Submitter
Jason Merrill

Created on 2023-12-02.00:00:00 last changed 3 months ago

Messages

Date: 2024-01-21.13:30:12

CWG 2024-01-19

It seems #2 should be chosen, because it is more specialized than #1.

Date: 2024-01-21.13:30:12

Proposed resolution (reviewed by CWG 2024-01-19):

Change in 13.7.7.3 [temp.func.order] paragraph 3 as follows:

Each function template M that is a member function with no explicit object parameter is considered to have a new first parameter of type X(M), described below, inserted in its function parameter list. If exactly one of the function templates was considered by overload resolution via a rewritten candidate (12.2.2.3 [over.match.oper]) with a reversed order of parameters, then the order of the function parameters in its transformed template is reversed. For a function template M with cv-qualifiers cv that is a non-static member of a class A:
  • The type X(M) is “rvalue reference to cv A” if the optional ref-qualifier of M is && or if M has no ref-qualifier and the positionally-corresponding parameter of the other transformed template has rvalue reference type; if this determination depends recursively upon whether X(M) is an rvalue reference type, it is not considered to have rvalue reference type.
  • Otherwise, X(M) is “lvalue reference to cv A”.
For a function template M that is a static member of a class A:
  • The type X(M) is the type of the object parameter of the other transformed template, if any.
  • Otherwise, no new first parameter is inserted.
[Note 2: This allows a non-static member to be ordered with respect to a static or non-member function and for the results to be equivalent to the ordering of two equivalent non-members. —end note]
Date: 2024-01-21.13:30:12

Consider:

  template <typename T>
  struct A {
    T f(this auto, auto);   // #1
    int f(auto);            // #2
  };
  int main() {
    A<int>().f(42);
  }

There is implementation divergence in the handling of this example: Clang and MSVC consider the example ambiguous, EDG chooses #1.

History
Date User Action Args
2024-01-21 13:30:12adminsetmessages: + msg7576
2024-01-21 13:30:12adminsetmessages: + msg7575
2024-01-21 13:30:12adminsetstatus: open -> review
2023-12-02 00:00:00admincreate