Issue1632

Title 1632. Lambda capture in member initializers
Status open Section 5.1.5 [expr.prim.lambda]
Submitter Vinny Romano

Created on 2013-03-04.00:00:00 by admin, last changed by admin.

Messages
msg4327 (view) Date: 2013-04-15.00:00:00

Notes from the April, 2013 meeting:

CWG agreed with the intent of this issue.

msg4289 (view) Date: 2017-02-06.00:00:00

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

A lambda-expression whose smallest enclosing scope is a block scope (3.3.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
2017-02-06 00:00:00adminsetsection: 5.1.2 [expr.prim.lambda] -> 5.1.5 [expr.prim.lambda]
2013-05-03 00:00:00adminsetmessages: + msg4327
2013-03-04 00:00:00admincreate