Saturday, October 29, 2011

lambda function in C++0x

Lambda function in C++0x

1. Simplify code. good for simple predicate (i.e. a condition check);
[](//input parameters){ //lambda function body}

2. Anonymous call, function to be defined at the point it is needed.

3. Lambda function can only use global variable and passed parameters, just as a math function, i.e.
sin, cos, pow etc.

4. No local variable in the containing scope, special capture operation has to be defined, if you want to
use the local variables, i.e. [=] by value, [&] by reference.

No comments: