1// Contributed by Iain Sandoe <iain@codesourcery.com>, December 2014. */ 2// { dg-do compile } 3// { dg-options "-std=c++11" } 4 5 6template<class Function> 7Function thing(Function fn, int a) 8{ 9 fn(a); 10 return fn; 11} 12 13int 14test (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} 23