<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2720</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="2720"></A><H4>2720.
  
Template validity rules for templated entities and alias templates
</H4>
<B>Section: </B>13.8.1&#160; [<A href="https://wg21.link/temp.res.general">temp.res.general</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Richard Smith
 &#160;&#160;&#160;

 <B>Date: </B>2023-03-29<BR>


<P>[Accepted as a DR at the June, 2023 meeting.]</P>

<P>Subclause 13.8.1 [<A href="https://wg21.link/temp.res.general#6">temp.res.general</A>] paragraph 6 specifies rules to
determine when a template is valid, but the specification is in terms
of "instantiation".  However, some kinds of templates (namely alias
templates) are not instantiated.</P>

<P>Further, the rule discusses only templates, but should apply to any
templated entity.</P>

<P><B>Proposed resolution (approved by CWG 2023-05-12):</B></P>

<P>Change in 13.8.1 [<A href="https://wg21.link/temp.res.general#6">temp.res.general</A>] paragraph 6 as follows:</P>

<BLOCKQUOTE>

<P>
The validity of a <DEL>template</DEL> <INS>templated entity</INS> may
be checked prior to any instantiation.  [<I>Note 3:</I> Knowing which
names are type names allows the syntax of every template to be checked
in this way. &#8212;<I>end note</I>]
</P>

<P>The program is ill-formed, no diagnostic required, if:
<UL>
<LI>no valid specialization, ignoring
<I><TT>static_assert</TT>-declaration</I>s that
fail <INS>(9.1 [<A href="https://wg21.link/dcl.pre">dcl.pre</A>])</INS>, can be generated for a
<DEL>template</DEL> <INS>templated entity</INS> or a substatement of a
constexpr if statement (8.5.2 [<A href="https://wg21.link/stmt.if">stmt.if</A>]) within
a <DEL>template</DEL> <INS>templated entity</INS> and
the <INS>innermost enclosing</INS> template is not instantiated,
or</LI>

<LI><INS>no specialization of an alias template
(13.7.8 [<A href="https://wg21.link/temp.alias">temp.alias</A>]) is valid and no specialization of the
alias template is named in the program, or</INS></LI>

<LI>any <I>constraint-expression</I> in the program, introduced or
otherwise, has (in its normal form) an atomic constraint A where no
satisfaction check of A could be well-formed and no satisfaction check
of A is performed, or</LI>

<LI>every valid specialization of a variadic template requires an
empty template parameter pack, or</LI>

<LI>a hypothetical instantiation of
a <DEL>template</DEL> <INS>templated entity</INS> immediately
following its definition would be ill-formed due to a
construct <INS>(other than a <TT>static_assert</TT>-declaration that
fails)</INS> that does not depend on a
template parameter, or</LI>

<LI>the interpretation of such a construct in the hypothetical
instantiation is different from the interpretation of the
corresponding construct in any actual instantiation of
the <DEL>template</DEL> <INS>templated entity</INS>.
</LI>
</UL>
</P>

</BLOCKQUOTE>

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