Example
The implementation currently supports the following features of the proposal:
int
sum = 0
;
std::for_each1 (begin, end, 2
[&, f = factor4] 3 (int5 n) 6 { sum += n * f; }7 );
std::for_each1 (begin, end, 2
[&, f = factor4] 3 (int5 n) 6 { sum += n * f; }7 );
- Lambda expressions can be passed to function templates, and are usable with the std::CallableN class of concepts.
- A lambda function can be defined wherever a primary-expression is expected.
- Lambdas can "capture" variables from the surrounding scope, by reference or copy.
- Initializer expressions, an extension to the proposal, are supported.
- Argument types must be explicitly annotated.
- Return types are deducable and, thus, may be omitted.
- The body must be a compound-statement.
- When used inside a member function, a lambda
- can capture this explicitly, or by default when it uses direct or indirect references to class members.
- has private access to the class.