This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 112e. See for the official list.


2314. Structured bindings and lambda capture

Section: 9.6  [dcl.struct.bind]     Status: dup     Submitter: Richard Smith     Date: 2016-08-14


  void f() {
   tuple<int, int> a;
   auto &[x, y] = a;
   [x] {};           // ok, captures reference to int member of 'a' by value
   [&] { use(x); };  // ok, capture reference by reference

  void g() {
   struct T { int a, b; } a;
   auto &[x, y] = a;
   [x] {};           // ill-formed, 'x' does not name a variable
   [&] { use(x); };  // ???

The standard is silent on whether and how identifiers of a decomposition declaration can be captured by a lambda.

Rationale (July, 2017):

This issue is a duplicate of issue 2308.