Title
Structured bindings and lambda capture
Status
dup
Section
9.6 [dcl.struct.bind]
Submitter
Richard Smith

Created on 2016-08-14.00:00:00 last changed 83 months ago

Messages

Date: 2017-07-15.00:00:00

Rationale (July, 2017):

This issue is a duplicate of issue 2308.

Date: 2022-11-20.07:54:16

Consider:

  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.

History
Date User Action Args
2018-02-27 00:00:00adminsetmessages: + msg6025
2016-08-14 00:00:00admincreate