- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambda.cpp
More file actions
Latest commit
65 lines (47 loc) · 638 Bytes
/
Copy pathlambda.cpp
File metadata and controls
65 lines (47 loc) · 638 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include<stdio.h>
#include<functional>
// ラムダ式を引数に
voidfunc(std::function< void() > _f)
{
_f();
}
voidfunc(std::function< void(int) > _f, int _n)
{
_f(_n);
}
voidmain()
{
func( [](int n) { printf("%d\n", n); }, 10 );
#if0
int a = 0;
// ラムダ式 無名関数
auto func = [&]()
{
a = 50;
printf("test\n");
};
func();
printf("a = %d\n", a);
#endif
#if0
int* b = &a;
auto func2 = [&]()
{
int c = 100;
b = &c;
};
func2();
printf("b = %d\n", *b);
#endif
auto f1 = []()
{
printf("f1\n");
};
auto f2 = []()
{
printf("f2\n");
};
func(f1);
func(f2);
getchar();
}