<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1164</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="1164"></A><H4>1164.
  
Partial ordering of <TT>f(T&amp;)</TT> and <TT>f(T&amp;&amp;)</TT>
</H4>
<B>Section: </B>13.10.3.2&#160; [<A href="https://wg21.link/temp.deduct.call">temp.deduct.call</A>]
 &#160;&#160;&#160;

 <B>Status: </B>C++11
 &#160;&#160;&#160;

 <B>Submitter: </B>US
 &#160;&#160;&#160;

 <B>Date: </B>2010-08-03<BR><BR>


<P>[Voted into the WP at the November, 2010 meeting.]</P>

<A href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3296.html#US77">N3092 comment
  US&#160;77<BR></A>

<P>The following example is ambiguous:</P>

<PRE>
    template&lt;typename T&gt; int f(T&amp;);
    template&lt;typename T&gt; int f(T&amp;&amp;);
    int i;
    int j = f(i);
</PRE>

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

<P>Because <TT>f(T&amp;)</TT> accepts a strict subset of the things
that <TT>f(T&amp;&amp;)</TT> does, it should be considered more
specialized by the partial ordering rules.</P>

<P><B>Proposed resolution (August, 2010):</B></P>

<P>Change 13.10.3.5 [<A href="https://wg21.link/temp.deduct.partial#9">temp.deduct.partial</A>] paragraph 9 as follows:</P>

<BLOCKQUOTE>

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

<UL>
<LI><P><INS>If the type from the argument template was
an lvalue reference and the type from the parameter template
was not, the argument type is considered to be more
specialized than the other; otherwise,</INS></P></LI>

<LI><P>
<DEL>and</DEL> if the type from the argument template
is more cv-qualified than the type from the parameter
template (as described above)<INS>, the argument</INS>
<DEL>that</DEL> type is considered to be more specialized
than the other<DEL>.</DEL><INS>; otherwise</INS>
</P></LI>

<LI><P>
<DEL>If neither type is more cv-qualified than the
other then</DEL> neither type is more specialized than the
other.</P></LI>

</UL>

</BLOCKQUOTE>

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

<BR><BR>
</BODY>
</HTML>
