Gobelijn API documentation
- generated for commit a0cbea7
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Friends
Macros
Pages
lambda-functor.cpp
Go to the documentation of this file.
1
#include <functional>
2
#include <iostream>
3
using
std::cout;
4
using
std::endl;
5
6
std::function<int(int)>
makeCountingAdder
(
int
& counter)
7
{
8
return
[&counter](
int
x) ->
int
{
9
int
val = counter + x;
10
counter++;
11
return
val;
12
};
13
}
14
15
int
main
()
16
{
17
int
counter = 40;
18
auto
adder =
makeCountingAdder
(counter);
19
cout << adder(2) << endl;
20
cout << adder(4) << endl;
21
cout << adder(8) << endl;
22
cout <<
"Current counter count: "
<< counter << endl;
23
}
main
int main()
Definition:
lambda-functor.cpp:15
makeCountingAdder
std::function< int(int)> makeCountingAdder(int &counter)
Definition:
lambda-functor.cpp:6
main
cpp
demo-functor
lambda-functor.cpp
Generated on Fri Feb 1 2019 09:33:32 for Gobelijn API documentation by
1.8.6