<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 700</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="700"></A><H4>700.
  
Constexpr member functions of class templates
</H4>
<B>Section: </B>9.2.6&#160; [<A href="https://wg21.link/dcl.constexpr">dcl.constexpr</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jens Maurer
 &#160;&#160;&#160;

 <B>Date: </B>27 June, 2008<BR>


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



<P>9.2.6 [<A href="https://wg21.link/dcl.constexpr#5">dcl.constexpr</A>] paragraph 5 applies only to &#8220;the
instantiated template specialization of a constexpr function
template;&#8221; it should presumably apply to non-template member
functions of a class template, as well.</P>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>This question is more involved than it might appear.  For example,
a constexpr member function is implicitly <TT>const</TT>; if the
<TT>constexpr</TT> specifier is ignored, does that make the member
function non-const?  Also, should this provision apply only to
dependent expressions in the function?  Should it be an error if no
constexpr function can be instantiated from the template, along the
lines of the permission given in 13.8 [<A href="https://wg21.link/temp.res#8">temp.res</A>] paragraph 8
for an implementation to diagnose a template definition from which no
valid specialization can be instantiated?</P>

<P><B>Notes from the July, 2009 meeting:</B></P>

<P>The consensus of the CWG was that an &#8220;ignored&#8221;
<TT>constexpr</TT> specifier in this case simply means that the
specialization is not constexpr, not that it is not const.  The
CWG also decided not to address the question of non-dependent
expressions that render a function template specialization
non-constexpr, leaving it to quality of implementation whether
a (warning) diagnostic is issued in such cases.</P>

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

<P>Change 9.2.6 [<A href="https://wg21.link/dcl.constexpr#5">dcl.constexpr</A>] paragraph 5 as follows:</P>

<BLOCKQUOTE>

If the instantiated template specialization of a constexpr
function template <INS>or member function of a class
template</INS> would fail to satisfy the requirements for a
constexpr function or constexpr constructor, <DEL>the
<TT>constexpr</TT> specifier is ignored</DEL> <INS>that
specialization is not a constexpr function or constexpr
constructor</INS>. <INS>[<I>Note:</I> if the function is a
member function it will still be <TT>const</TT> as described
below. Implementations are encouraged to issue a warning if a
function was rendered not constexpr by a non-dependent
construct. &#8212;<I>end note</I>]</INS>

</BLOCKQUOTE>

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