gcc/testsuite/obj-c++.dg/lambda-0.mm
raw| 1 | // Contributed by Iain Sandoe <[email protected]>, December 2014. */ |
| 2 | // { dg-do compile } |
| 3 | // { dg-options "-std=c++11" } |
| 4 | |
| 5 | |
| 6 | template<class Function> |
| 7 | Function thing(Function fn, int a) |
| 8 | { |
| 9 | fn(a); |
| 10 | return fn; |
| 11 | } |
| 12 | |
| 13 | int |
| 14 | test (int *arr, unsigned n) |
| 15 | { |
| 16 | int total = 0; |
| 17 | for (unsigned i=0; i<n; i++) { |
| 18 | int a = arr[i]; |
| 19 | thing ([&total] (int a) { total += a; }, a); |
| 20 | } |
| 21 | return total; |
| 22 | } |