gcc/testsuite/g++.dg/cpp0x/lambda/lambda-capture-const-ref.C
raw| 1 | // { dg-do run { target c++11 } } |
| 2 | // { dg-skip-if "requires hosted libstdc++ for cassert" { ! hostedlib } } |
| 3 | #include <cassert> |
| 4 | |
| 5 | int main() { |
| 6 | int i = 1, j = 2; |
| 7 | const int& ci = i; |
| 8 | [&ci, &j] () -> void { j = ci; } (); |
| 9 | assert(i == 1); |
| 10 | assert(j == 1); |
| 11 | //[&ci] () -> void { ci = 0; } (); { dg-error: cannot assign to const int& } |
| 12 | |
| 13 | return 0; |
| 14 | } |
| 15 |