lambda

文章目录

C++11 introduced lambdas, allowing the definition of inline functionality, which can be used as a parameter or a local object. Lambdas change the way the C++ statndard library is used.

A lambda is a definition of functionality that can be defined inside statements and expressions. Thus, you can use a lambda as an inline function. The minimal lambda function has no parameters and simply does something.

1
2
3
4
5
6
7
8
9
10
11
12
13
[] {
std::cout << "hello lambda"<<std::endl;
}

[] {
std::cout<< "hello lambda"<<std::endl;
}();

auto l = [] {
std::cout<< "hello lambda"<<std::endl;
}

l();