This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-19


1763. Length mismatch in template type deduction

Section: 13.10.3.6  [temp.deduct.type]     Status: open     Submitter: Canada     Date: 2013-09-23

N3690 comment CA 4

It is not clear how an example like the following is to be handled:

  template <typename U>
  struct A {
    template <typename V> operator A<V>();
  };

  template <typename T>
  void foo(A<void (T)>);

  void foo();

  int main() {
    A<void (int, char)> a;
    foo<int>(a);
    foo(a); // deduces T to be int
  }

In sub13.10.3.6 [temp.deduct.type] paragraph 10, deduction from a function type considers P/A pairs from the parameter-type-list only where the "P" function type has a parameter. Deduction is not specified to fail if there are additional parameters in the corresponding "A" function type.

Notes from the September, 2013 meeting:

CWG agreed that this example should not be accepted. The existing rules seem to cover this case (deduction is not specified to “succeed,” so it's a reasonable conclusion that it fails), but it might be helpful to be clearer.