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

2023-01-15


1275. Incorrect comment in example of template parameter pack restriction

Section: 13.2  [temp.param]     Status: CD3     Submitter: Johannes Schaub     Date: 2011-03-25

[Voted into the WP at the February, 2012 meeting; moved to DR at the October, 2012 meeting.]

The following example from 13.2 [temp.param] paragraph 11 is incorrect:

  // U cannot be deduced or specified
  template<class... T, class... U> void f() { }
  template<class... T, class U> void g() { }

In fact, U can be deduced to an empty sequence by 13.10.2 [temp.arg.explicit] paragraph 3:

A trailing template parameter pack (13.7.4 [temp.variadic]) not otherwise deduced will be deduced to an empty sequence of template arguments.

Proposed resolution (August, 2011):

Change 13.2 [temp.param] paragraph 11 as follows:

...A template parameter pack of a function template shall not be followed by another template parameter unless that template parameter can be deduced from the parameter-type-list of the function template or has a default argument (13.10.3 [temp.deduct]). [Example:

  template<class T1 = int, class T2> class B;   // error

  // U cannot be deduced from the parameter-type-list or specified
  template<class... T, class... U> void f() { } // error
  template<class... T, class U> void g() { }    // error

end example]