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

2022-07-01


2121. More flexible lambda syntax

Section: 7.5.5.1  [expr.prim.lambda.general]     Status: WP     Submitter: EWG     Date: 2015-05-06

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

The grammar in 7.5.5 [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.)

Proposed resolution (May, 2015):

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

  2. Change 7.5.5 [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.5 [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...

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.