gcc/testsuite/g++.dg/cpp0x/lambda/lambda-array.C
raw| 1 | // Test that array capture by copy works. |
| 2 | // { dg-do run { target c++11 } } |
| 3 | |
| 4 | struct A |
| 5 | { |
| 6 | int i; |
| 7 | A(int i): i(i) {} |
| 8 | A(const A& a): i(a.i+1) {} |
| 9 | }; |
| 10 | |
| 11 | int main() |
| 12 | { |
| 13 | A ar[4][3] = { { 10, 20, 30 }, |
| 14 | { 40, 50, 60 }, |
| 15 | { 70, 80, 90 }, |
| 16 | { 100, 110, 120 } }; |
| 17 | int i = [ar] { return ar[1][1]; }().i; |
| 18 | return (i!= 52); |
| 19 | } |