CWG Issue 2373 (original) (raw)

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

2025-11-05


2373. Incorrect handling of static member function templates in partial ordering

Section: 13.7.7.3 [temp.func.order]Status: CD5Submitter: Richard SmithDate: 2018-02-14

[Accepted as a DR at the November, 2018 (San Diego) meeting.]

According to 13.7.7.3 [temp.func.order] paragraph 3,

...If only one of the function templates M is a non-static member of some class A, M is considered to have a new first parameter inserted in its function parameter list. Given cv as the cv-qualifiers of M (if any), the new parameter is of type “rvalue reference to _cv A_” if the optional ref-qualifier of M is && or if M has no ref-qualifier and the first parameter of the other template has rvalue reference type. Otherwise, the new parameter is of type “lvalue reference to _cv A_”. [Note: This allows a non-static member to be ordered with respect to a non-member function and for the results to be equivalent to the ordering of two equivalent non-members. —_end note_]

This gives the wrong answer for an example like:

struct Foo { template static T* f(Foo*) { return nullptr; }

template <typename T, typename A1>
T* f(const A1&) { return nullptr; }

};

int main() { Foo x; x.f(&x); }

Presumably this should say something like,

...If only one of the function templates M is a member function, and that function is a non-static member...

Proposed resolution (October, 2018):

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

...If only one of the function templates M is amember function, and that function is anon-static member of some class A, M is considered to have a new first parameter inserted in its function parameter list. Given cv as the cv-qualifiers of M (if any), the new parameter is of type “rvalue reference to _cv A_” if the optional ref-qualifier of M is && or if M has no ref-qualifier and the first parameter of the other template has rvalue reference type. Otherwise, the new parameter is of type “lvalue reference to _cv A_”. [Note: This allows a non-static member to be ordered with respect to a non-member function and for the results to be equivalent to the ordering of two equivalent non-members. —_end note_]