Created on 2014-07-02.00:00:00 last changed 133 months ago
Proposed resolution:
Change the grammar in 5.1.2 [expr.prim.lambda] paragraph 1
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
Remove from 5.1.2 [expr.prim.lambda] paragraph 4
Modify in 5.1.2 [expr.prim.lambda] paragraph 5If a lambda-expression does not include a lambda-declarator, it is as if the lambda-declarator were ().
This function call operator or operator template is declaredconst(9.3.1) if and only if thelambda-expression's parameter-declaration-clause is not followed bylambda-declarator does not contain the keywordmutable.
It has been reported that various people have noticed that it's possible to write
auto lambda = []{};
but not
auto lambda2 = [] mutable {};
In the mutable case, parentheses are required, thus:
auto lambda3 = []() mutable {};
The proposed consistency fix is to change the grammar to allow omitting the parentheses for mutable lambdas as well.
An additional question EWG needs to decide is whether the empty parentheses could be omitted for other cases besides mutable, such as
[] -> float {return 42;};
[] noexcept {foo();};
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2014-11-21 17:12:23 | admin | set | messages: + msg172 |
| 2014-07-02 00:00:00 | admin | create | |