<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2091</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="2091"></A><H4>2091.
  
Deducing reference non-type template 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>CD4
 &#160;&#160;&#160;

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

 <B>Date: </B>2015-03-05<BR>


<P>[Adopted at the June, 2016 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 <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.

</BLOCKQUOTE>

<P>This gives the wrong result for an example like:</P>

<PRE>
  template&lt;int &amp;&gt; struct X;
  template&lt;int &amp;N&gt; void f(X&lt;N&gt;&amp;);
  int n;
  void g(X&lt;n&gt; &amp;x) { f(x); }
</PRE>

<P>Here, <TT>P</TT> is <TT>X&lt;N&gt;</TT>, which contains
<TT>&lt;i&gt;</TT>.  The type of <TT>i</TT> is <TT>int&amp;</TT>.
The corresponding value from <TT>A</TT> is <TT>n</TT>, which is a
glvalue of type <TT>int</TT>.  Presumably this should be valid.</P>

<P>I think this rule means to say something like,</P>

<BLOCKQUOTE>

If <TT>P</TT> has a form that contains <TT>&lt;i&gt;</TT>, and the type
of <TT>i</TT> differs from the type of the corresponding template
parameter of the template named by the enclosing <I>simple-template-id</I>,
deduction fails.

</BLOCKQUOTE>

<P><B>Proposed resolution (March, 2016):</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 <TT>P</TT> has a form that contains <TT>&lt;i&gt;</TT>,
and if the type of <DEL>the corresponding value
of <TT>A</TT> differs from the type
of</DEL> <TT>i</TT> <INS>differs from the type of the
corresponding template parameter of the template named by
the enclosing <I>simple-template-id</I></INS>, deduction
fails. If <TT>P</TT> has a form that
contains <TT>[i]</TT>...

</BLOCKQUOTE>

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