<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1770</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 118.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-13</P>
<HR>
<A NAME="1770"></A><H4>1770.
  
Type matching of non-type template parameters and arguments
</H4>
<B>Section: </B>13.10.3.6&#160; [<A href="https://wg21.link/temp.deduct.type">temp.deduct.type</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Canada
 &#160;&#160;&#160;

 <B>Date: </B>2013-09-24<BR><BR>


<A href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3903.html#CA15">N3690 comment
  CA&#160;15<BR></A>

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

<P>According to 13.10.3.6 [<A href="https://wg21.link/temp.deduct.type#17">temp.deduct.type</A>] paragraph 17,</P>

<BLOCKQUOTE>

If, in the declaration of a function template with a
non-type <I>template-parameter</I>, the non-type <I>template-parameter</I>
is used in an expression in the function parameter-list and, if the
corresponding <I>template-argument</I> is deduced,
the <I>template-argument</I> type shall match the type of
the <I>template-parameter</I> exactly, except that
a <I>template-argument</I> deduced from an array bound may be of any
integral type.

</BLOCKQUOTE>

<P>This does not cover return types, leaving the outcome of an example
like the following unclear:</P>

<PRE>
  template &lt;int N&gt; struct A;

  template &lt;short N&gt;
  A&lt;N&gt; *foo();

  void bar() {
    A&lt;1&gt; *(*fp)(void) = &amp;foo;
  }
</PRE>

<P><B>Proposed resolution (September, 2013):</B></P>

<P>Change 13.10.3.6 [<A href="https://wg21.link/temp.deduct.type#17">temp.deduct.type</A>] paragraph 17 as follows:</P>

<BLOCKQUOTE>

If<DEL>, in the declaration of a function template with a
non-type <I>template-parameter</I>, the non-type <I>template-parameter</I>
is used in an expression in the function parameter-list and, if the
corresponding <I>template-argument</I> is deduced,
the <I>template-argument</I> type shall match the type of
the <I>template-parameter</I> exactly, except that
a <I>template-argument</I> deduced from an array bound may be of any
integral type</DEL> <INS><TT>P</TT> has a form that
contains <TT>&lt;i&gt;</TT>, and if the type of the corresponding value
of <TT>A</TT> differs from the type of <TT>i</TT>, deduction
fails. If <TT>P</TT> has a form that contains <TT>[i]</TT>, and if the type
of <TT>i</TT> is not an integral type, deduction fails</INS>.<SUP>147</SUP>
[<I>Example:</I>...

</BLOCKQUOTE>

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