<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1392</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="1392"></A><H4>1392.
  
Explicit conversion functions for references and non-references
</H4>
<B>Section: </B>12.2.2.7&#160; [<A href="https://wg21.link/over.match.ref">over.match.ref</A>]
 &#160;&#160;&#160;

 <B>Status: </B>CD3
 &#160;&#160;&#160;

 <B>Submitter: </B>Jason Merrill
 &#160;&#160;&#160;

 <B>Date: </B>2011-09-08<BR>


<P>[Moved to DR at the October, 2012 meeting.]</P>



<P>In 12.2.2.6 [<A href="https://wg21.link/over.match.conv">over.match.conv</A>], dealing with non-reference
initialization, direct initialization considers as candidate functions
only those that</P>

<BLOCKQUOTE>

yield type <TT>T</TT> or a type that can be converted to type
<TT>T</TT> with a qualification conversion

</BLOCKQUOTE>

<P>By contrast, 12.2.2.7 [<A href="https://wg21.link/over.match.ref">over.match.ref</A>], dealing with reference
binding, requires only that the type returned be reference-compatible
with the target, permitting both qualification conversions and
derived-to-base conversions.  This discrepancy is presumably
unintentional.</P>

<P><B>Proposed resolution (February, 2012):</B></P>

<P>Change 12.2.2.7 [<A href="https://wg21.link/over.match.ref#1">over.match.ref</A>] paragraph 1 as follows:</P>

<BLOCKUOTE>

<P>...the candidate functions are selected as follows:</P>

<UL>
<LI><P>The conversion functions of <TT>S</TT> and its base classes
are considered<DEL>, except that for copy-initialization, only the
non-explicit conversion functions are considered</DEL>. Those
<INS>non-explicit conversion functions</INS> that are not hidden
within <TT>S</TT> and yield type &#8220;lvalue reference to
<I>cv2</I> <TT>T2</TT>&#8221; (when 9.5.4 [<A href="https://wg21.link/dcl.init.ref">dcl.init.ref</A>]
requires an lvalue result) or &#8220;<I>cv2</I> <TT>T2</TT>&#8221; or
&#8220;rvalue reference to <I>cv2</I> <TT>T2</TT>&#8221; (when
9.5.4 [<A href="https://wg21.link/dcl.init.ref">dcl.init.ref</A>] requires an rvalue result), where
&#8220;<I>cv1</I> <TT>T</TT>&#8221; is reference-compatible
(9.5.4 [<A href="https://wg21.link/dcl.init.ref">dcl.init.ref</A>]) with &#8220;<I>cv2</I>
<TT>T2</TT>&#8221;, are candidate functions. <INS>For
direct-initialization, those explicit conversion functions that are not
hidden within <TT>S</TT> and yield type &#8220;lvalue reference to
<I>cv2</I> <TT>T2</TT>,&#8221; or &#8220;<I>cv2</I> <TT>T2</TT>&#8221; or
&#8220;rvalue reference to <I>cv2</I> <TT>T2</TT>,&#8221;
respectively, where <TT>T2</TT> is the same type as <TT>T</TT> or can
be converted to type <TT>T</TT> with a qualification conversion
(7.3.6 [<A href="https://wg21.link/conv.qual">conv.qual</A>]), are also candidate
functions.</INS>
</P></LI>

</UL>

</BLOCKUOTE>

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