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

2024-07-24


904. Parameter packs in lambda-captures

Section: 7.5.6.3  [expr.prim.lambda.capture]     Status: CD2     Submitter: Faisal Vali     Date: 23 May, 2009

[Voted into WP at March, 2010 meeting.]

The following is not allowed by the current syntax of lambda-capture but would be useful:

    template <typename ...Args> void f(Args... args) {
      auto l = [&, args...] { return g(args...); };
    }

Proposed resolution (October, 2009):

  1. Change the grammar in 7.5.6 [expr.prim.lambda] paragraph 1 as follows:

  2. Add a new paragraph at the end of 7.5.6 [expr.prim.lambda]:

  3. A capture followed by an ellipsis is a pack expansion (13.7.4 [temp.variadic]). [Example:

        template<typename ...Args>
        void f(Args... args) {
          auto l = [&, args...] { return g(args...); };
          l();
        }
    
    

    end example]

  4. Add a new bullet to the list in 13.7.4 [temp.variadic] paragraph 4:

  5. [Editorial note: the editor may wish to consider sorting the bullets in this list in order of section reference.]