<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1874</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="1874"></A><H4>1874.
  
Type vs non-type template parameters with <TT>class</TT> keyword
</H4>
<B>Section: </B>13.2&#160; [<A href="https://wg21.link/temp.param">temp.param</A>]
 &#160;&#160;&#160;

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

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

 <B>Date: </B>2014-02-18<BR>


<P>[Moved to DR at the November, 2014 meeting.]</P>

<P>The Standard is not clear enough that a template parameter like
<TT>class&#160;T</TT> is to be interpreted as a type parameter and
not an ill-formed non-type parameter of class type <TT>T</TT>.</P>

<P><B>Proposed resolution (October, 2014):</B></P>

<OL>
<LI><P>Change 13.2 [<A href="https://wg21.link/temp.param#2">temp.param</A>] paragraph 2 as follows,
moving the example from paragraph 3 to paragraph 2:</P></LI>

<BLOCKQUOTE>

<P>There is no semantic difference between <TT>class</TT>
and <TT>typename</TT> in a <I>template-parameter</I>.
<TT>typename</TT> followed by an <I>unqualified-id</I> names
a template type parameter. <TT>typename</TT> followed by
a <I>qualified-id</I> denotes the type in a
non-type<SUP>137</SUP> <I>parameter-declaration</I>.
<INS>A <I>template-parameter</I> of the form <TT>class</TT>
<I>identifier</I> is a <I>type-parameter</I>.
[<I>Example:</I></INS>
</P>

<PRE>
<INS>  class T { /* ... */ };
  int i;

  template&lt;class T, T i&gt; void f(T t) {
    T t1 = i;      //<SPAN CLASS="cmnt"> template-parameters </SPAN>T<SPAN CLASS="cmnt"> and </SPAN>i
    ::T t2 = ::i;  //<SPAN CLASS="cmnt"> global namespace members </SPAN>T<SPAN CLASS="cmnt"> and </SPAN>i
  }</INS>
</PRE>

<P>
<INS>Here, the template <TT>f</TT> has
a <I>type-parameter</I> called <TT>T</TT>, rather than an
unnamed non-type <I>template-parameter</I> of class
<TT>T</TT>. &#8212;<I>end example</I>].</INS> A storage
class shall not be specified in a <I>template-parameter</I>
declaration. Types shall not be defined in
a <I>template-parameter</I> declaration. <DEL>[<I>Note:</I> A
template parameter may be a class template. For example...
&#8212;<I>end note</I>]</DEL>
</P>

</BLOCKQUOTE>

<LI><P>Change 13.2 [<A href="https://wg21.link/temp.param#3">temp.param</A>] paragraph 3 as follows,
moving the example from paragraph 2 to paragraph 3:</P></LI>

<BLOCKQUOTE>

<P>A <I>type-parameter</I> whose identifier does not follow
an ellipsis defines its <I>identifier</I> to be
a <I>typedef-name</I> (if declared with <TT>class</TT>
or <TT>typename</TT>) or <I>template-name</I> (if declared
with <TT>template</TT>) in the scope of the template
declaration. <DEL>[<I>Note:</I> Because of the name lookup
rules, a <I>template-parameter</I> that could be interpreted
as either a non-type <I>template-parameter</I> or
a <I>type-parameter</I> (because its identifier is the name
of an already existing class) is taken as
a <I>type-parameter</I>. For example... &#8212;<I>end
note</I>]</DEL> <INS>[<I>Note:</I> A template parameter may
be a class template.  For example,</INS>
</P>

<PRE>
<INS>  template&lt;class T&gt; class myarray { /* ... */ };

  template&lt;class K, class V, template&lt;class T&gt; class C = myarray&gt;
  class Map {
    C&lt;K&gt; key;
    C&lt;V&gt; value;
  };</INS>
</PRE>

<P><INS>&#8212;<I>end note</I>]</INS></P>

</BLOCKQUOTE>

</OL>

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