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

2024-03-20


1533. Function pack expansion for member initialization

Section: 13.7.4  [temp.variadic]     Status: CD3     Submitter: Jonathan Caves     Date: 2012-08-06

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

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.

Proposed resolution (October, 2012):

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

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