Title
More flexible lambda syntax
Status
cd6
Section
7.5.6.1 [expr.prim.lambda.general]
Submitter
EWG

Created on 2015-05-06.00:00:00 last changed 27 months ago

Messages

Date: 2015-10-15.00:00:00

Notes from the October, 2015 meeting:

Additional wording is needed in the proposed resolution in paragraph 5 to handle the potential absence of the parameter declaration clause.

Date: 2015-05-15.00:00:00

Proposed resolution (May, 2015):

  1. Change the grammar in 7.5.6 [expr.prim.lambda] paragraph 1 as follows:

    • lambda-expression:
        lambda-introducer lambda-declaratoropt compound-statement

      ...

      lambda-declarator:
        ( parameter-declaration-clause ) mutableopt
          exception-specificationopt attribute-specifier-seqopt trailing-return-typeopt
        mutableopt exception-specificationopt attribute-specifier-seqopt trailing-return-typeopt
  2. Change 7.5.6 [expr.prim.lambda] paragraph 4 as follows:

  3. If a lambda-expression does not include a lambda-declarator, it is as if the lambda-declarator were (). The lambda return type...
  4. Change 7.5.6 [expr.prim.lambda] paragraph 5 as follows:

  5. The closure type for a non-generic lambda-expression has a public inline function call operator (12.4.4 [over.call]) whose parameters and return type are described by the lambda-expression's parameter-declaration-clause and trailing-return-type respectively. For a generic lambda... This function call operator or operator template is declared const (11.4.3 [class.mfct.non.static]) if and only if the lambda-expression's parameter-declaration-clause is not followed by lambda-declarator does not contain the keyword mutable. It is neither...
Date: 2021-02-15.00:00:00

[Adopted at the February, 2021 meeting as paper P1102R2.]

The grammar in 7.5.6 [expr.prim.lambda] paragraph 1 allows for omitting the the parameter list but only for a non-mutable lambda, i.e., it does not permit

    auto lambda = [] mutable { };

This should be addressed, and the possibility of other abbreviated forms should be considered, such as:

    [] -> float { return 42; }
    [] noexcept { foo(); }

(This is EWG issue 135.)

History
Date User Action Args
2022-08-19 07:54:33adminsetstatus: wp -> cd6
2021-11-15 00:00:00adminsetstatus: accepted -> wp
2021-02-17 00:00:00adminsetstatus: drafting -> accepted
2015-11-10 00:00:00adminsetmessages: + msg5642
2015-11-10 00:00:00adminsetstatus: review -> drafting
2015-05-25 00:00:00adminsetmessages: + msg5473
2015-05-06 00:00:00admincreate