1#include <functional>
2
3int foo(int x, int y) {
4 return x + y - 1; // Source foo start line
5}
6
7struct Bar {
8 int operator()() {
9 return 66 ; // Source Bar::operator()() start line
10 }
11 int add_num(int i) const { return i + 3 ; } // Source Bar::add_num start line
12 int num_ = 0 ;
13} ;
14
15int main (int argc, char *argv[])
16{
17 int acc = 42;
18 std::function<int (int,int)> f1 = foo;
19 std::function<int (int)> f2 = [acc,f1] (int x) -> int {
20 return x+f1(acc,x); // Source lambda used by f2 start line
21 };
22
23 auto f = [](int x, int y) { return x + y; }; // Source lambda used by f3 start line
24 auto g = [](int x, int y) { return x * y; } ;
25 std::function<int (int,int)> f3 = argc %2 ? f : g ;
26
27 Bar bar1 ;
28 std::function<int ()> f4( bar1 ) ;
29 std::function<int (const Bar&, int)> f5 = &Bar::add_num;
30 std::function<int(Bar const&)> f_mem = &Bar::num_;
31
32 return f_mem(bar1) + // Set break point at this line.
33 f1(acc,acc) + // Source main invoking f1
34 f2(acc) + // Set break point at this line.
35 f3(acc+1,acc+2) + // Set break point at this line.
36 // TODO reenable this case when std::function formatter supports
37 // general callable object case.
38 //f4() + // Set break point at this line.
39 f5(bar1, 10); // Set break point at this line.
40}
41

source code of lldb/test/API/lang/cpp/std-function-step-into-callable/main.cpp