<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 493</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="493"></A><H4>493.
  
Type deduction from a <TT>bool</TT> context
</H4>
<B>Section: </B>13.10.3.4&#160; [<A href="https://wg21.link/temp.deduct.conv">temp.deduct.conv</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>John Spicer
 &#160;&#160;&#160;

 <B>Date: </B>17 Dec 2004<BR>


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

<P>An expression used in an <TT>if</TT> statement is implicitly
converted to type <TT>bool</TT> (8.5 [<A href="https://wg21.link/stmt.select">stmt.select</A>]).
According to the rules of template argument deduction for
conversion functions given in 13.10.3.4 [<A href="https://wg21.link/temp.deduct.conv">temp.deduct.conv</A>],
the following example is ill-formed:</P>

<PRE>
    struct X {
      template&lt;class T&gt; operator const T&amp;() const;
    };
    int main()
    {
      if( X() ) {}
    }
</PRE>

<P>Following the logic in 13.10.3.4 [<A href="https://wg21.link/temp.deduct.conv">temp.deduct.conv</A>],
<TT>A</TT> is <TT>bool</TT> and <TT>P</TT> is <TT>const T</TT>
(because cv-qualification is dropped from <TT>P</TT> before the
reference is removed), and deduction fails.</P>

<P>It's not clear whether this is the intended outcome or
not.</P>

<P><B>Notes from the April, 2005 meeting:</B></P>

<P>The CWG observed that there is nothing special about either
<TT>bool</TT> or the context in the example above; instead, it
will be a problem wherever a copy occurs, because cv-qualification
is always dropped in a copy operation.  This appears to be a case
where the conversion deduction rules are not properly symmetrical
with the rules for arguments.  The example should be accepted.</P>

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

<P>This issue is resolved by the resolution of
<A HREF="976.html">issue 976</A>.</P>

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