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

2024-10-26


1164. Partial ordering of f(T&) and f(T&&)

Section: 13.10.3.2  [temp.deduct.call]     Status: C++11     Submitter: US     Date: 2010-08-03

[Voted into the WP at the November, 2010 meeting.]

N3092 comment US 77

The following example is ambiguous:

    template<typename T> int f(T&);
    template<typename T> int f(T&&);
    int i;
    int j = f(i);

Because of the special deduction rule for lvalues passed to rvalue-reference parameters, deduction produces f(int&) for both templates, and they are indistinguishable.

Because f(T&) accepts a strict subset of the things that f(T&&) does, it should be considered more specialized by the partial ordering rules.

Proposed resolution (August, 2010):

Change 13.10.3.5 [temp.deduct.partial] paragraph 9 as follows:

If, for a given type, deduction succeeds in both directions (i.e., the types are identical after the transformations above) and both P and A were reference types (before being replaced with the type referred to above):

[Editing note: this change transforms the running text at the end of the paragraph into a bulleted list.]