Title
Default arguments and function parameter packs
Status
open
Section
9.3.4.7 [dcl.fct.default]
Submitter
Jonathan Caves

Created on 2013-01-25.00:00:00 last changed 136 months ago

Messages

Date: 2013-09-15.00:00:00

Notes from the September, 2013 meeting:

CWG agreed that this example should be accepted; the restriction on default arguments applies to the template declaration itself, not to its specializations.

Date: 2013-08-15.00:00:00

Additional note (August, 2013):

9.3.4.7 [dcl.fct.default] paragraph 4 explicitly allows for a function parameter pack to follow a parameter with a default argument:

In a given function declaration, each parameter subsequent to a parameter with a default argument shall have a default argument supplied in this or a previous declaration or shall be a function parameter pack.

However, any instantiation of such a function template with a non-empty pack expansion would result in a function declaration in which one or more parameters without default arguments (from the pack expansion) would follow a parameter with a default argument and thus would be ill-formed. Such a function template declaration thus violates 13.8 [temp.res] paragraph 8:

If every valid specialization of a variadic template requires an empty template parameter pack, the template is ill-formed, no diagnostic required.

Although the drafting review teleconference of 2013-08-26 suggested closing the issue as NAD, it is being kept open to discuss and resolve this apparent contradiction.

Date: 2013-04-15.00:00:00

Notes from the April, 2013 meeting:

CWG agreed that the example should be ill-formed.

Date: 2013-01-25.00:00:00

It is not clear from 9.3.4.7 [dcl.fct.default] whether the following is well-formed or not:

  template<typename... T>
  void f2(int a = 0, T... b, int c = 1);

  f2<>(); // parameter a has the value 0 and parameter c has the value 1

(T... b is a non-deduced context per 13.10.3.6 [temp.deduct.type] paragraph 5, so the template arguments must be specified explicitly.)

History
Date User Action Args
2013-10-14 00:00:00adminsetmessages: + msg4652
2013-09-03 00:00:00adminsetmessages: + msg4516
2013-09-03 00:00:00adminsetstatus: drafting -> open
2013-05-03 00:00:00adminsetmessages: + msg4335
2013-05-03 00:00:00adminsetstatus: open -> drafting
2013-01-25 00:00:00admincreate