Title
Function pack expansion for member initialization
Status
cd3
Section
13.7.4 [temp.variadic]
Submitter
Jonathan Caves

Created on 2012-08-06.00:00:00 last changed 130 months ago

Messages

Date: 2013-04-15.00:00:00

[Moved to DR at the April, 2013 meeting.]

Date: 2012-10-15.00:00:00

Proposed resolution (October, 2012):

Change 13.7.4 [temp.variadic] paragraph 4 as follows:

...Pack expansions can occur in the following contexts:

  • ...

  • In a mem-initializer-list (11.9.3 [class.base.init]) for a mem-initializer whose mem-initializer-id denotes a base class; the pattern is a the mem-initializer.

  • ...

Date: 2012-08-06.00:00:00

The list of pack expansion contexts in 13.7.4 [temp.variadic] paragraph 4 includes a mem-initializer-list, with no restriction on whether the mem-initializer corresponds to a base class or a member. However, it appears from 11.9.3 [class.base.init] paragraph 15 that such a pack expansion is intended for bases:

A mem-initializer followed by an ellipsis is a pack expansion (13.7.4 [temp.variadic]) that initializes the base classes specified by a pack expansion in the base-specifier-list for the class.

This is not conclusive, however, and use of a pack expansion with a mem-initializer for a member could be used with packs containing zero or one element:

  class S { };

  template<typename... T> class X {
  public:
    X(T ...args) : data_(args)... { }
  private:
    S data_;
  };

  int main() {
    S s;
    X<> x1;
    X<S> x2(s);
  }

The Standard should be clarified as to whether such a usage is permitted or not.

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2013-10-14 00:00:00adminsetstatus: dr -> drwp
2013-05-03 00:00:00adminsetmessages: + msg4425
2013-05-03 00:00:00adminsetstatus: ready -> dr
2012-11-03 00:00:00adminsetmessages: + msg4069
2012-11-03 00:00:00adminsetstatus: open -> ready
2012-08-06 00:00:00admincreate