<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2235</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="2235"></A><H4>2235.
  
Partial ordering and non-dependent types
</H4>
<B>Section: </B>13.10.3.5&#160; [<A href="https://wg21.link/temp.deduct.partial">temp.deduct.partial</A>]
 &#160;&#160;&#160;

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

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

 <B>Date: </B>2016-02-25<BR>


<P>[Accepted as a DR at the March, 2018 (Jacksonville) meeting.]</P>



<P>Paragraph 12 of 13.10.3.5 [<A href="https://wg21.link/temp.deduct.partial">temp.deduct.partial</A>] contains the following
example:</P>

<PRE>
  template &lt;class T&gt; T f(int);        //<SPAN CLASS="cmnt"> #1</SPAN>
  template &lt;class T, class U&gt; T f(U); //<SPAN CLASS="cmnt"> #2</SPAN>
  void g() {
    f&lt;int&gt;(1);                        //<SPAN CLASS="cmnt"> calls #1</SPAN>
  }
</PRE>

<P>However, paragraph 4 states,</P>

<BLOCKQUOTE>

If a particular <TT>P</TT> contains no <I>template-parameter</I>s that
participate in template argument deduction, that <TT>P</TT> is not used to
determine the ordering.

</BLOCKQUOTE>

<P>Thus, we ignore the <TT>P=int</TT>, <TT>A=U</TT> case and deduction
succeeds for the <TT>P=U</TT>, <TT>A=int</TT> case, so both templates
are at least as specialized as each other. And consider:</P>

<PRE>
  template &lt;class... T&gt; struct V {};
  template &lt;class... Ts, class... Us&gt; void Foo(V&lt;Ts...&gt;, V&lt;Us&amp;...&gt;) {} //<SPAN CLASS="cmnt"> #3 </SPAN>
  template &lt;class... Us&gt; void Foo(V&lt;&gt;, V&lt;Us&amp;...&gt;) {}                   //<SPAN CLASS="cmnt"> #4 </SPAN>
  void h() {
    Foo(V&lt;&gt;(), V&lt;&gt;());
  }
</PRE>

<P>The intent is that this should call #4; that template clearly ought to
be more specialized.</P>

<P><B>Proposed resolution (November, 2017)</B></P>

<OL>
<LI><P>Change 13.10.3.5 [<A href="https://wg21.link/temp.deduct.partial#4">temp.deduct.partial</A>] paragraph 4 as
follows:</P></LI>:

<BLOCKQUOTE>

Each type nominated above from the parameter template and the corresponding
type from the argument template are used as the types of <TT>P</TT>
and <TT>A</TT>. <DEL>If a particular <TT>P</TT> contains
no <I>template-parameter</I>s that participate in template argument
deduction, that <TT>P</TT> is not used to determine the ordering.</DEL>

</BLOCKQUOTE>

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

<BLOCKQUOTE>

...If a template parameter is used only in non-deduced contexts and is not
explicitly specified, template argument deduction fails. [<I>Note:</I>
Under 13.10.3.2 [<A href="https://wg21.link/temp.deduct.call">temp.deduct.call</A>] <DEL>and
13.10.3.5 [<A href="https://wg21.link/temp.deduct.partial">temp.deduct.partial</A>]</DEL>, if <TT>P</TT> contains
no <I>template-parameter</I>s that appear in deduced contexts, no deduction
is done, so <TT>P</TT> and <TT>A</TT> need not have the same
form. &#8212;<I>end note</I>]

</BLOCKQUOTE>

</OL>

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