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

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

 <B>Submitter: </B>John Spicer
 &#160;&#160;&#160;

 <B>Date: </B>2016-05-24<BR>


<P>[Accepted as a DR at the February, 2019 meeting.]</P>

<P>The status of an example like the following is not clear:</P>

<PRE>
  template &lt;typename... T&gt;              struct A;
  template &lt;&gt;                           struct A&lt;&gt; {};
  template &lt;typename T, typename... Ts&gt; struct A&lt;T, Ts...&gt; : A&lt;Ts...&gt; {};
  struct B : A&lt;int&gt; {};

  template &lt;typename... T&gt;
  void f(const A&lt;T...&gt;&amp;);

  void g() {
    f(B{});
  }
</PRE>

<P>This seems to be ambiguous in the current wording because
<TT>A&lt;&gt;</TT> and <TT>A&lt;int&gt;</TT> both succeed in deduction.
It would be reasonable to prefer the more derived specialization.
</P>

<P><B>Notes from the March, 2018 meeting:</B></P>

<P>The relevant specification is in 13.10.3.2 [<A href="https://wg21.link/temp.deduct.call">temp.deduct.call</A>] bullet
4.3 and paragraph 5, which specifies that if there is more than one
possible deduced <TT>A</TT>, deduction fails. The consensus was to add
wording similar to that of overload resolution preferring
&#8220;nearer&#8221; base classes.</P>

<P><B>Proposed resolution (November, 2018):</B></P>

<P>Change 13.10.3.2 [<A href="https://wg21.link/temp.deduct.call#4.3">temp.deduct.call</A>] bullet 4.3 as follows:</P>

<BLOCKQUOTE>

<P>In general, the deduction process attempts to find template
argument values that will make the deduced A identical to A
(after the type A is transformed as described above). However,
there are three cases that allow a difference:</P>

<UL>
<LI><P>...</P></LI>

<LI><P>If <TT>P</TT> is a class and <TT>P</TT> has the
form <I>simple-template-id</I>, then the transformed <TT>A</TT>
can be a derived class <INS><TT>D</TT></INS> of the
deduced <TT>A</TT>. Likewise, if <TT>P</TT> is a pointer to a
class of the form <I>simple-template-id</I>, the
transformed <TT>A</TT> can be a pointer to a derived
class <INS><TT>D</TT></INS> pointed to by the
deduced <TT>A</TT>. <INS>However, if there is a class <TT>C</TT>
that is a (direct or indirect) base class of <TT>D</TT> and
derived (directly or indirectly) from a class <TT>B</TT> and that
would be a valid deduced <TT>A</TT>, the deduced <TT>A</TT>
cannot be <TT>B</TT> or pointer to <TT>B</TT>, respectively.
[<I>Example:</I></INS>
</P></LI>

<PRE>
<INS>  template &lt;typename... T&gt; struct X;
  template &lt;&gt; struct X&lt;&gt; {};
  template &lt;typename T, typename... Ts&gt; struct X&lt;T, Ts...&gt; : X&lt;Ts...&gt; {};
  struct D : X&lt;int&gt; {};

  template &lt;typename... T&gt;
  int f(const X&lt;T...&gt;&amp;);
  int x = f(D());  //<SPAN CLASS="cmnt"> calls </SPAN>f&lt;int&gt;<SPAN CLASS="cmnt">, not </SPAN>f&lt;&gt;
                   //<SPAN CLASS="cmnt"> </SPAN>B<SPAN CLASS="cmnt"> is </SPAN>X&lt;&gt;<SPAN CLASS="cmnt">, </SPAN>C<SPAN CLASS="cmnt"> is </SPAN>X&lt;int&gt;</INS>
</PRE>

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

</UL>

</BLOCKQUOTE>

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