Title
Partial ordering and non-dependent types
Status
cd5
Section
13.10.3.5 [temp.deduct.partial]
Submitter
Richard Smith

Created on 2017-02-06.00:00:00 last changed 48 months ago

Messages

Date: 2017-11-15.00:00:00

Proposed resolution (November, 2017)

  1. Change 13.10.3.5 [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 13.10.3.6 [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 13.10.3.2 [temp.deduct.call] and 13.10.3.5 [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]
Date: 2018-03-15.00:00:00

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

Paragraph 12 of 13.10.3.5 [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
2020-12-15 00:00:00adminsetstatus: dr -> cd5
2018-04-11 00:00:00adminsetstatus: tentatively ready -> dr
2018-02-27 00:00:00adminsetmessages: + msg5874
2018-02-27 00:00:00adminsetstatus: open -> tentatively ready
2017-02-06 00:00:00admincreate