1 | #include <string> |
2 | #include <unordered_map> |
3 | #include <unordered_set> |
4 | |
5 | int g_the_foo = 0; |
6 | |
7 | int thefoo_rw(int arg = 1) { |
8 | if (arg < 0) |
9 | arg = 0; |
10 | if (!arg) |
11 | arg = 1; |
12 | g_the_foo += arg; |
13 | return g_the_foo; |
14 | } |
15 | |
16 | int main() { |
17 | |
18 | char buffer[sizeof(std::unordered_map<int, std::string>)] = {0}; |
19 | std::unordered_map<int, std::string> &corrupt_map = *(std::unordered_map<int, std::string> *)buffer; |
20 | |
21 | // Make a typedef to ensure functionality when typedefs are used. |
22 | typedef std::unordered_map<int, std::string> UnorderedMap; |
23 | UnorderedMap map; // Set break point at this line. |
24 | map.emplace(args: 1, args: "hello" ); |
25 | map.emplace(args: 2, args: "world" ); |
26 | map.emplace(args: 3, args: "this" ); |
27 | map.emplace(args: 4, args: "is" ); |
28 | map.emplace(args: 5, args: "me" ); |
29 | thefoo_rw(); // Set break point at this line. |
30 | |
31 | // Make a typedef to ensure functionality when typedefs are used. |
32 | typedef std::unordered_multimap<int, std::string> UnorderedMultiMap; |
33 | UnorderedMultiMap mmap; |
34 | mmap.emplace(args: 1, args: "hello" ); |
35 | mmap.emplace(args: 2, args: "hello" ); |
36 | mmap.emplace(args: 2, args: "world" ); |
37 | mmap.emplace(args: 3, args: "this" ); |
38 | mmap.emplace(args: 3, args: "this" ); |
39 | mmap.emplace(args: 3, args: "this" ); |
40 | thefoo_rw(); // Set break point at this line. |
41 | |
42 | // Make a typedef to ensure functionality when typedefs are used. |
43 | typedef std::unordered_set<int> IntsUnorderedSet; |
44 | IntsUnorderedSet iset; |
45 | iset.emplace(args: 1); |
46 | iset.emplace(args: 2); |
47 | iset.emplace(args: 3); |
48 | iset.emplace(args: 4); |
49 | iset.emplace(args: 5); |
50 | thefoo_rw(); // Set break point at this line. |
51 | |
52 | // Make a typedef to ensure functionality when typedefs are used. |
53 | typedef std::unordered_set<std::string> StringsUnorderedSet; |
54 | StringsUnorderedSet sset; |
55 | sset.emplace(args: "hello" ); |
56 | sset.emplace(args: "world" ); |
57 | sset.emplace(args: "this" ); |
58 | sset.emplace(args: "is" ); |
59 | sset.emplace(args: "me" ); |
60 | thefoo_rw(); // Set break point at this line. |
61 | |
62 | // Make a typedef to ensure functionality when typedefs are used. |
63 | typedef std::unordered_multiset<int> IntsUnorderedMultiSet; |
64 | IntsUnorderedMultiSet imset; |
65 | imset.emplace(args: 1); |
66 | imset.emplace(args: 2); |
67 | imset.emplace(args: 2); |
68 | imset.emplace(args: 3); |
69 | imset.emplace(args: 3); |
70 | imset.emplace(args: 3); |
71 | thefoo_rw(); // Set break point at this line. |
72 | |
73 | // Make a typedef to ensure functionality when typedefs are used. |
74 | typedef std::unordered_multiset<std::string> StringsUnorderedMultiSet; |
75 | StringsUnorderedMultiSet smset; |
76 | smset.emplace(args: "hello" ); |
77 | smset.emplace(args: "world" ); |
78 | smset.emplace(args: "world" ); |
79 | smset.emplace(args: "is" ); |
80 | smset.emplace(args: "is" ); |
81 | thefoo_rw(); // Set break point at this line. |
82 | |
83 | return 0; |
84 | } |
85 | |