xref: /llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp (revision 6703812688b84100a159ec793f677952ea8e3eba)
1 #include <string>
2 #include <map>
3 
4 #define intint_map std::map<int, int>
5 #define strint_map std::map<std::string, int>
6 #define intstr_map std::map<int, std::string>
7 #define strstr_map std::map<std::string, std::string>
8 
9 int g_the_foo = 0;
10 
thefoo_rw(int arg=1)11 int thefoo_rw(int arg = 1)
12 {
13 	if (arg < 0)
14 		arg = 0;
15 	if (!arg)
16 		arg = 1;
17 	g_the_foo += arg;
18 	return g_the_foo;
19 }
20 
main()21 int main()
22 {
23     intint_map ii;
24 
25     ii[0] = 0; // Set break point at this line.
26     ii[1] = 1;
27 
28     intint_map::iterator it = ii.begin();
29     intint_map::const_iterator const_it = ii.cbegin();
30     std::printf("%d %d\n", it->second, const_it->second);
31 
32     thefoo_rw(1); // Set break point at this line.
33     ii[2] = 0;
34     ii[3] = 1;
35 	thefoo_rw(1);  // Set break point at this line.
36 	ii[4] = 0;
37     ii[5] = 1;
38     ii[6] = 0;
39     ii[7] = 1;
40     thefoo_rw(1);  // Set break point at this line.
41     ii[85] = 1234567;
42 
43     ii.clear();
44 
45     strint_map si;
46     thefoo_rw(1);  // Set break point at this line.
47 
48     si["zero"] = 0;
49 	thefoo_rw(1);  // Set break point at this line.
50     si["one"] = 1;
51     si["two"] = 2;
52     si["three"] = 3;
53 	thefoo_rw(1);  // Set break point at this line.
54     si["four"] = 4;
55 
56     si.clear();
57     thefoo_rw(1);  // Set break point at this line.
58 
59     intstr_map is;
60     thefoo_rw(1);  // Set break point at this line.
61     is[85] = "goofy";
62     is[1] = "is";
63     is[2] = "smart";
64     is[3] = "!!!";
65     thefoo_rw(1);  // Set break point at this line.
66 
67     is.clear();
68     thefoo_rw(1);  // Set break point at this line.
69 
70     strstr_map ss;
71     thefoo_rw(1);  // Set break point at this line.
72 
73     ss["ciao"] = "hello";
74     ss["casa"] = "house";
75     ss["gatto"] = "cat";
76     thefoo_rw(1);  // Set break point at this line.
77     ss["a Mac.."] = "..is always a Mac!";
78 
79     ss.clear();
80     thefoo_rw(1);  // Set break point at this line.
81     return 0;
82 }
83