Lambda functions
From cppreference.com
This section is incomplete |
Declares an unnamed function object
Contents |
Syntax
[ Template:sparam ] ( Template:sparam ) -> Template:sparam
|
(C++11) | ||||||||
[ Template:sparam ] ( Template:sparam )
|
(C++11) | ||||||||
Explanation
capture | - | specifies which symbols visible in the scope where the function is declared will be visible inside the function body.
A list of symbols can be passed as follows:
|
params | - | The list of parameters, as in named functions |
ret | - | Return type. If not present it's implied by the function return statements ( or void if it doesn't return any value) |
Example 1
This example shows how to pass a lambda to a generic algorithm Template:example cpp
Example 2
Objects resulting from a lambda declaration, can be stored in std::function objects Template:example cpp
See also
(C++11) |
copyable wrapper of any copy constructible callable object (class template) |