Title
Lambda capture in member initializers
Status
cd5
Section
7.5.6.3 [expr.prim.lambda.capture]
Submitter
Vinny Romano

Created on 2013-03-04.00:00:00 last changed 47 months ago

Messages

Date: 2013-04-15.00:00:00

Notes from the April, 2013 meeting:

CWG agreed with the intent of this issue.

Date: 2017-10-15.00:00:00

[Accepted as a DR as part of paper P0588R1 at the October, 2017 meeting.]

According to 7.5.6 [expr.prim.lambda] paragraph 9,

A lambda-expression whose smallest enclosing scope is a block scope (6.4.3 [basic.scope.block]) is a local lambda expression; any other lambda-expression shall not have a capture-list in its lambda-introducer. The reaching scope of a local lambda expression is the set of enclosing scopes up to and including the innermost enclosing function and its parameters.

Consequently, lambdas appearing in mem-initializers and brace-or-equal-initializers cannot have a capture-list. However, these expressions are evaluated in the context of the constructor and are permitted to access this and non-static data members.

Should the definition of a local lambda be modified to permit capturing lambdas within these contexts?

History
Date User Action Args
2020-12-15 00:00:00adminsetstatus: open -> cd5
2013-05-03 00:00:00adminsetmessages: + msg4358
2013-03-04 00:00:00admincreate