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

2024-04-18


1118. Implicit lambda capture via explicit copy constructor

Section: 7.5.5.3  [expr.prim.lambda.capture]     Status: NAD     Submitter: FI     Date: 2010-08-02

N3092 comment FI 19

According to 7.5.5 [expr.prim.lambda] paragraph 21,

When the lambda-expression is evaluated, the entities that are captured by copy are used to direct-initialize each corresponding non-static data member of the resulting closure object.

This apparently means that if the capture-default is to copy, entities captured by default, implicitly, are copied even in cases where the copy constructors of such entities are explicit. It should be required that such entities be captured explicitly instead.

See also issue 1020.

Rationale (August, 2010):

The behavior is according to the original design and is similar to what would happen if the constructor of the closure object initialized the members for the captured entities using mem-initializers. CWG did not see sufficient motivation to change the design.