Lambda Functions
Lambda functions provide in-place functionality. The compiler gets a lot of insight and has therefore great optimisation potential. Lambda functions can receive their arguments by value or by reference. They can capture their environment by value, by reference and with C++14 by move.
std
::
vector
<
int
>
myVec
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
};
std
::
for_each
(
myVec
.
begin
(),
myVec
.
end
(),
[](
int
&
i
){
i
=
i
*
i
;
});
// 1 4 9 16 25 36 49 64 81 100