Skip to content

Commit 56da654

Browse files
committed
Save captureless lambda in field
1 parent b907253 commit 56da654

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎tests/unit/lambda_as_field.cpp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,19 @@ template <typename T> auto wrap(T fn) {
2020
return [fn](int x) { return fn(x) + 1; };
2121
}
2222

23+
int count = 0;
24+
2325
int main() {
26+
{
27+
Guard g{[]() { count++; }};
28+
assert(count == 0);
29+
}
30+
assert(count == 1);
31+
32+
Holder n{[](int x) { return x + 1; }, 0};
33+
assert(n.call(2) == 3);
34+
assert(n.calls == 1);
35+
2436
int cleaned = 0;
2537
{
2638
Guard g{[&cleaned]() { cleaned++; }};

0 commit comments

Comments
 (0)