Title
Incorrect handling of static member function templates in partial ordering
Status
cd5
Section
13.7.7.3 [temp.func.order]
Submitter
Richard Smith

Created on 2018-02-14.00:00:00 last changed 48 months ago

Messages

Date: 2018-10-15.00:00:00

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 a member function, and that function 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]
Date: 2018-11-15.00:00:00

[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 <typename T>
    static T* f(Foo*) { return nullptr; }

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

  int main() {
    Foo x;
    x.f<int>(&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...
History
Date User Action Args
2020-12-15 00:00:00adminsetmessages: + msg6417
2018-02-14 00:00:00admincreate