Issue2235

Title 2235. Partial ordering and non-dependent types
Status dr Section 17.9.2.4 [temp.deduct.partial]
Submitter Richard Smith

Created on 2017-02-06.00:00:00 by admin, last changed by admin.

Messages
msg5994 (view) Date: 2017-11-15.00:00:00

Proposed resolution (November, 2017)

  1. Change 17.9.2.4 [temp.deduct.partial] paragraph 4 as follows:

  2. :
    Each type nominated above from the parameter template and the corresponding type from the argument template are used as the types of P and A. If a particular P contains no template-parameters that participate in template argument deduction, that P is not used to determine the ordering.
  3. Change 17.9.2.5 [temp.deduct.type] paragraph 4 as follows:

  4. ...If a template parameter is used only in non-deduced contexts and is not explicitly specified, template argument deduction fails. [Note: Under 17.9.2.1 [temp.deduct.call] and 17.9.2.4 [temp.deduct.partial], if P contains no template-parameters that appear in deduced contexts, no deduction is done, so P and A need not have the same form. —end note]
msg5803 (view) Date: 2018-03-15.00:00:00

[Accepted at the March, 2018 (Jacksonville) meeting.]

Paragraph 12 of 17.9.2.4 [temp.deduct.partial] contains the following example:

  template <class T> T f(int);        // #1
  template <class T, class U> T f(U); // #2
  void g() {
    f<int>(1);                        // calls #1
  }

However, paragraph 4 states,

If a particular P contains no template-parameters that participate in template argument deduction, that P is not used to determine the ordering.

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

  template <class... T> struct V {}; 
  template <class... Ts, class... Us> void Foo(V<Ts...>, V<Us&...>) {} // #3 
  template <class... Us> void Foo(V<>, V<Us&...>) {}                   // #4 
  void h() { 
    Foo(V<>(), V<>()); 
  } 

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

History
Date User Action Args
2018-04-11 00:00:00adminsetstatus: tentatively ready -> dr
2018-02-27 00:00:00adminsetstatus: open -> tentatively ready
submitter: unknown -> Richard Smith
section: 14.8.2.5 [temp.deduct.type] -> 17.9.2.4 [temp.deduct.partial]
2018-02-27 00:00:00adminsetmessages: + msg5994
2017-02-06 00:00:00admincreate