summaryrefslogtreecommitdiff
path: root/gcc/testsuite/obj-c++.dg/lambda-0.mm
blob: 41482fdba88a9fc2737c008f75494a0a63d4bbc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Contributed by Iain Sandoe <iain@codesourcery.com>, December 2014.  */
// { dg-do compile }
// { dg-options "-std=c++11" }


template<class Function>
Function thing(Function fn, int a)
{
  fn(a);
  return fn;
}

int
test (int *arr, unsigned n)
{
  int total = 0;
  for (unsigned i=0; i<n; i++) {
    int a = arr[i];
    thing ([&total] (int a) { total += a; }, a);
  }
  return total;
}