Title
Partial ordering between variadic and non-variadic function templates
Status
c++17
Section
13.10.3.5 [temp.deduct.partial]
Submitter
Steve Clamage

Created on 2013-12-30.00:00:00 last changed 83 months ago

Messages

Date: 2016-11-15.00:00:00

[Moved to DR at the November, 2016 meeting.]

Date: 2016-06-15.00:00:00

Proposed resolution (June, 2016):

This issue is resolved by the resolution of issue 1395.

Date: 2014-02-15.00:00:00

Notes from the February, 2014 meeting:

CWG felt that the best approach would be, when comparing P and A, if A is a pack and P is not, A should be repeated for each remaining instance of P and then use the variadic/nonvariadic criterion as a late tiebreaker if the result is still ambiguous. This would apply in the general case (including 13.10.3.5 [temp.deduct.partial]), not just in function calls.

Date: 2013-12-30.00:00:00

Given the following example,

  template <class ...T> int f(T*...)  { return 1; }
  template <class T>  int f(const T&) { return 2; }
  void g() {
    f((int*)0);
  }

the current specification makes the call ambiguous because deduction fails in both directions: with A being T and P being T* in one direction and A being T* and P being T, because 13.10.3.5 [temp.deduct.partial] paragraph 8 says,

If A was transformed from a function parameter pack and P is not a parameter pack, type deduction fails.

It is not clear whether this is the best outcome, however; it might be better to consider the first template more specialized, with the variadic/non-variadic test being a tie-breaker if there is no other reason to prefer one over the other based on the parameter types.

History
Date User Action Args
2018-02-27 00:00:00adminsetmessages: + msg6172
2018-02-27 00:00:00adminsetstatus: dr -> c++17
2017-02-06 00:00:00adminsetmessages: + msg6095
2017-02-06 00:00:00adminsetstatus: drafting -> dr
2014-03-03 00:00:00adminsetmessages: + msg4899
2014-03-03 00:00:00adminsetstatus: open -> drafting
2013-12-30 00:00:00admincreate