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

2024-04-18


2091. Deducing reference non-type template arguments

Section: 13.10.3.6  [temp.deduct.type]     Status: CD4     Submitter: Richard Smith     Date: 2015-03-05

[Adopted at the June, 2016 meeting.]

According to 13.10.3.6 [temp.deduct.type] paragraph 17,

If P has a form that contains <i>, and if the type of the corresponding value of A differs from the type of i, deduction fails.

This gives the wrong result for an example like:

  template<int &> struct X;
  template<int &N> void f(X<N>&);
  int n;
  void g(X<n> &x) { f(x); }

Here, P is X<N>, which contains <i>. The type of i is int&. The corresponding value from A is n, which is a glvalue of type int. Presumably this should be valid.

I think this rule means to say something like,

If P has a form that contains <i>, and the type of i differs from the type of the corresponding template parameter of the template named by the enclosing simple-template-id, deduction fails.

Proposed resolution (March, 2016):

Change 13.10.3.6 [temp.deduct.type] paragraph 17 as follows:

If P has a form that contains <i>, and if the type of the corresponding value of A differs from the type of i differs from the type of the corresponding template parameter of the template named by the enclosing simple-template-id, deduction fails. If P has a form that contains [i]...