1 #include <functional> 2 3 int foo(int x, int y) { 4 return x + y - 1; 5 } 6 7 struct Bar { 8 int operator()() { 9 return 66 ; 10 } 11 int add_num(int i) const { return i + 3 ; } 12 int add_num2(int i) { 13 std::function<int (int)> add_num2_f = [](int x) { 14 return x+1; 15 }; 16 17 return add_num2_f(i); // Set break point at this line. 18 } 19 } ; 20 21 int foo2() { 22 auto f = [](int x) { 23 return x+1; 24 }; 25 26 std::function<int (int)> foo2_f = f; 27 28 return foo2_f(10); // Set break point at this line. 29 } 30 31 int main (int argc, char *argv[]) 32 { 33 int acc = 42; 34 std::function<int (int,int)> f1 = foo; 35 std::function<int (int)> f2 = [acc,f1] (int x) -> int { 36 return x+f1(acc,x); 37 }; 38 39 auto f = [](int x, int y) { return x + y; }; 40 auto g = [](int x, int y) { return x * y; } ; 41 std::function<int (int,int)> f3 = argc %2 ? f : g ; 42 43 Bar bar1 ; 44 std::function<int ()> f4( bar1 ) ; 45 std::function<int (const Bar&, int)> f5 = &Bar::add_num; 46 47 int foo2_result = foo2(); 48 int bar_add_num2_result = bar1.add_num2(10); 49 50 return f1(acc,acc) + f2(acc) + f3(acc+1,acc+2) + f4() + f5(bar1, 10); // Set break point at this line. 51 } 52