Can a closure class be a literal type?
7.5.5 [expr.prim.lambda]
John Spicer

Created on 2012-02-22.00:00:00 last changed 81 months ago


Date: 2014-02-15.00:00:00

[Moved to DR at the February, 2014 meeting.]

Date: 2014-01-15.00:00:00

Proposed resolution (January, 2014):

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

The type of the lambda-expression (which is also the type of the closure object) is a unique, unnamed non-union class type — called the closure type — whose properties are described below. This class type is not neither an aggregate (9.4.2 [dcl.init.aggr]) nor a literal type (6.8 [basic.types]). The closure type is declared...
Date: 2013-09-15.00:00:00

Notes from the September, 2013 meeting:

At the suggestion of EWG, it was decided that closure types should be specified as not literal, rather than being unspecified as in the April, 2013 proposed resolution. The issue has thus been returned to "drafting" status.

Date: 2013-04-15.00:00:00

Proposed resolution (April, 2013) [superseded]:

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

...An implementation may define the closure type differently from what is described below provided this does not alter the observable behavior of the program other than by changing:

  • the size and/or alignment of the closure type,

  • whether the closure type is trivially copyable (Clause Clause 11 [class]),

  • whether the closure type is a literal type (6.8 [basic.types]),
  • whether the closure type is a standard-layout class (Clause Clause 11 [class]), or

  • whether the closure type is a POD class (Clause Clause 11 [class]).

Date: 2013-05-03.00:00:00

Additional note, April, 2013:

Some have expressed the opinion that such portability issues are just “par for the course,” and that specifying these characteristics at this point might unnecessarily limit the ability to extend the language in desirable directions at some point in the future.

Date: 2014-03-03.00:00:00
N3690 comment ES 9

The description of the characteristics of a closure class in 7.5.5 [expr.prim.lambda] leaves open the possibility that such a class might be a literal type, although it could also be a non-literal type. It would probably be good to specify that a closure class is not a literal type, in the interests of portability.

On a related note, it might be wise to remove the implementation freedom to make a closure class either a POD or not a POD; it seems only to be an invitation for portability problems with no real advantage.

Date User Action Args
2014-11-24 00:00:00adminsetstatus: dr -> c++14
2014-03-03 00:00:00adminsetmessages: + msg4938
2014-03-03 00:00:00adminsetstatus: tentatively ready -> dr
2014-01-20 00:00:00adminsetmessages: + msg4722
2014-01-20 00:00:00adminsetstatus: drafting -> tentatively ready
2013-10-14 00:00:00adminsetmessages: + msg4621
2013-10-14 00:00:00adminsetstatus: ready -> drafting
2013-05-03 00:00:00adminsetmessages: + msg4308
2013-05-03 00:00:00adminsetmessages: + msg4307
2013-05-03 00:00:00adminsetstatus: open -> ready
2012-02-22 00:00:00admincreate