gcc/testsuite/g++.dg/cpp0x/lambda/lambda-non-const.C
raw| 1 | // { dg-do run { target c++11 } } |
| 2 | // { dg-skip-if "requires hosted libstdc++ for cassert" { ! hostedlib } } |
| 3 | |
| 4 | #include <cassert> |
| 5 | |
| 6 | template<typename F> |
| 7 | void call(F f) { f(); } |
| 8 | |
| 9 | int main() { |
| 10 | call([] () -> void {}); |
| 11 | call([] () mutable -> void {}); |
| 12 | |
| 13 | int i = -1; |
| 14 | call([i] () mutable -> void { i = 0; }); |
| 15 | assert(i == -1); |
| 16 | |
| 17 | return 0; |
| 18 | } |
| 19 |