<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1100</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="1100"></A><H4>1100.
  
<TT>constexpr</TT> conversion functions and non-type template arguments
</H4>
<B>Section: </B>7.7&#160; [<A href="https://wg21.link/expr.const">expr.const</A>]
 &#160;&#160;&#160;

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

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

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


<P>[Voted into the WP at the March, 2011 meeting as part of paper N3260.]</P>



<P>According to 13.4.3 [<A href="https://wg21.link/temp.arg.nontype#1">temp.arg.nontype</A>] paragraph 1, one of the
possibilities for a <I>template-argument</I> for a non-type,
non-template <I>template-parameter</I> is</P>

<UL><LI><P>an integral constant expression (including a
constant expression of literal class type that can be used
as an integral constant expression as described in
7.7 [<A href="https://wg21.link/expr.const">expr.const</A>])</P></LI></UL>

<P>However, the requirement for such a literal class type is
(7.7 [<A href="https://wg21.link/expr.const#5">expr.const</A>] paragraph 5):</P>

<BLOCKQUOTE>

...that class type shall have a single non-explicit conversion
function to an integral or enumeration type and that
conversion function shall be constexpr.

</BLOCKQUOTE>

<P>Note that this normative requirement for a single
conversion function is contradicted by the example in that
paragraph, which reads in significant part,</P>

<PRE>
    struct A {
      constexpr A(int i) : val(i) { }
      constexpr operator int() { return val; }
      constexpr operator long() { return 43; }
    private:
      int val;
    };
    template&lt;int&gt; struct X { };
    constexpr A a = 42;
    X&lt;a&gt; x; //<SPAN CLASS="cmnt"> OK: unique conversion to </SPAN>int
</PRE>

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

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

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