repo.or.cz
/
official-gcc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Rebase.
[official-gcc.git]
/
gcc
/
testsuite
/
g++.dg
/
cpp0x
/
lambda
/
lambda-nested.C
blob
c8ea46a980fe8ffb8fdd7301d8e9d50fb68323b8
1
// { dg-do run { target c++11 } }
2
3
#include <cassert>
4
5
struct A {
6
int i;
7
A(): i(42) { }
8
int f() {
9
return [this]{
10
return [=]{ return i; }();
11
}();
12
}
13
};
14
15
int main() {
16
int i = 1;
17
18
[] (int& i) -> void {
19
[&] () -> void {
20
i = 2;
21
} ();
22
} (i);
23
24
assert(i == 2);
25
26
[&] () -> void {
27
[&i] () -> void {
28
i = 3;
29
} ();
30
} ();
31
32
assert(i == 3);
33
34
[&] () -> void {
35
[&] () -> void {
36
i = 4;
37
} ();
38
} ();
39
40
assert(i == 4);
41
i = 4;
42
43
[&] () -> void {
44
[=] () mutable -> void {
45
i = 5;
46
} ();
47
} ();
48
49
assert(i == 4);
50
51
[=] () mutable -> void {
52
[&] () -> void {
53
i = 6;
54
} ();
55
} ();
56
57
assert(i == 4);
58
59
assert (A().f() == 42);
60
61
return 0;
62
}