Movatterモバイル変換


[0]ホーム

URL:


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

2025-12-20


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

Section:13.7.7.3  [temp.func.order]    Status:CD5    Submitter:Richard Smith    Date: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 templatesM is anon-static member of some classA,M isconsidered to have a new first parameter inserted in itsfunction parameter list. Givencv as thecv-qualifiers ofM (if any), the new parameter is oftype “rvalue reference tocv A” if theoptionalref-qualifier ofM is && orifM has noref-qualifier and the firstparameter of the other template has rvalue referencetype. Otherwise, the new parameter is of type “lvaluereference tocv A”. [Note: This allows anon-static member to be ordered with respect to a non-memberfunction and for the results to be equivalent to theordering of two equivalent non-members. —endnote]

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 templatesM is a memberfunction, 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 templatesM is amember function, and that function is anon-static member of some classA,M isconsidered to have a new first parameter inserted in itsfunction parameter list. Givencv as thecv-qualifiers ofM (if any), the new parameter is oftype “rvalue reference tocv A” if theoptionalref-qualifier ofM is && orifM has noref-qualifier and the firstparameter of the other template has rvalue referencetype. Otherwise, the new parameter is of type “lvaluereference tocv A”. [Note: This allows anon-static member to be ordered with respect to a non-memberfunction and for the results to be equivalent to theordering of two equivalent non-members. —endnote]



[8]ページ先頭

©2009-2026 Movatter.jp