Title
Capturing rvalue references to functions by copy
Status
cd4
Section
7.5.5.3 [expr.prim.lambda.capture]
Submitter
Hubert Tong

Created on 2015-03-07.00:00:00 last changed 87 months ago

Messages

Date: 2015-09-15.00:00:00

Proposed resolution (September, 2015):

Change 7.5.5 [expr.prim.lambda] paragraph 15 as follows:

An entity is captured by copy if it is implicitly captured and the capture-default is = or if it is explicitly captured with a capture that is not of the form & identifier or & identifier initializer. For each entity captured by copy, an unnamed non-static data member is declared in the closure type. The declaration order of these members is unspecified. The type of such a data member is the referenced type if the entity is a reference to an object, an lvalue reference to the referenced function type if the entity is a reference to a function, or the type of the corresponding captured entity if the entity is not a reference to an object, or the referenced type otherwise. [Note: If the captured entity is a reference to a function, the corresponding data member is also a reference to a function. —end note] A member of an anonymous union shall not be captured by copy.
Date: 2016-02-15.00:00:00

[Adopted at the February, 2016 meeting.]

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

An entity is captured by copy if it is implicitly captured and the capture-default is = or if it is explicitly captured with a capture that is not of the form & identifier or & identifier initializer. For each entity captured by copy, an unnamed non-static data member is declared in the closure type. The declaration order of these members is unspecified. The type of such a data member is the type of the corresponding captured entity if the entity is not a reference to an object, or the referenced type otherwise.

It's not clear how to handle capture by copy when the entity is an rvalue reference to function. In particular, this appears to be a contradiction with 7.5.5 [expr.prim.lambda] paragraph 3,

An implementation shall not add members of rvalue reference type to the closure type.
History
Date User Action Args
2017-02-06 00:00:00adminsetstatus: tentatively ready -> cd4
2015-11-10 00:00:00adminsetmessages: + msg5594
2015-11-10 00:00:00adminsetstatus: drafting -> tentatively ready
2015-03-07 00:00:00admincreate