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
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.
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:For a function template M that is a 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”.
[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]
- 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.
CWG 2024-01-19
It seems #2 should be chosen, because it is more specialized than #1.