<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 744</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="744"></A><H4>744.
  
Matching template arguments with template template parameters with parameter packs
</H4>
<B>Section: </B>13.4.4&#160; [<A href="https://wg21.link/temp.arg.template">temp.arg.template</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Faisal Vali
 &#160;&#160;&#160;

 <B>Date: </B>2 November, 2008<BR>


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

<P>According to 13.4.4 [<A href="https://wg21.link/temp.arg.template#3">temp.arg.template</A>] paragraph 3,</P>

<BLOCKQUOTE>

A <I>template-argument</I> matches a template <I>template-parameter</I> (call it <TT>P</TT>)
when each of the template parameters in the <I>template-parameter-list</I> of
the <I>template-argument</I>'s corresponding class template or template
alias (call it <TT>A</TT>) matches the corresponding template parameter in the
<I>template-parameter-list</I> of <TT>P</TT>. When <TT>P</TT>'s
<I>template-parameter-list</I> contains a template parameter pack
(13.7.4 [<A href="https://wg21.link/temp.variadic">temp.variadic</A>]), the template parameter pack will match
zero or more template parameters or template parameter packs in the
<I>template-parameter-list</I> of <TT>A</TT> with the same type and
form as the template parameter pack in <TT>P</TT> (ignoring whether
those template parameters are template parameter packs).

</BLOCKQUOTE>

<P>The immediately-preceding example, however, assumes that a parameter
pack in the parameter will match only a parameter pack in the argument:</P>

<PRE>
    template&lt;class T&gt; class A { /* ... */ };
    template&lt;class T, class U = T&gt; class B { /* ... */ };
    template&lt;class ... Types&gt; class C { /* ... */ };

    template&lt;template&lt;class ...&gt; class Q&gt; class Y { /* ... */ };

    Y&lt;A&gt; ya;  //<SPAN CLASS="cmnt"> ill-formed: a template parameter pack does not match a template parameter</SPAN>
    Y&lt;B&gt; yb;  //<SPAN CLASS="cmnt"> ill-formed: a template parameter pack does not match a template parameter</SPAN>
    Y&lt;C&gt; yc;  //<SPAN CLASS="cmnt"> OK</SPAN>
</PRE>

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

<P>Change the final three lines of the second example in
13.4.4 [<A href="https://wg21.link/temp.arg.template#2">temp.arg.template</A>] paragraph 2 as follows:</P>

<PRE>
    Y&lt;A&gt; ya;  //<SPAN CLASS="cmnt"> <DEL>ill-formed: a template parameter pack does not match a template parameter</DEL> <INS>OK</INS></SPAN>
    Y&lt;B&gt; yb;  //<SPAN CLASS="cmnt"> <DEL>ill-formed: a template parameter pack does not match a template parameter</DEL> <INS>OK</INS></SPAN>
    Y&lt;C&gt; yc;  //<SPAN CLASS="cmnt"> OK</SPAN>
</PRE>

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