| 70 | }; |
| 71 | |
| 72 | bool SC::VectorMapTest::vectorMapSnippet() |
| 73 | { |
| 74 | //! [VectorMapSnippet] |
| 75 | VectorMap<String, int> map; |
| 76 | SC_TRY(map.insertIfNotExists({"A", 2})); // Allocates a String |
| 77 | SC_TRY(map.insertIfNotExists({"B", 3})); // Allocates a String |
| 78 | const int* value; |
| 79 | SC_TRY(map.contains("A", value) && *value == 2); // <-- "A" is a StringView, avoiding allocation |
| 80 | SC_TRY(map.contains("B", value) && *value == 3); // <-- "B" is a StringView, avoiding allocation |
| 81 | SC_TRY(not map.contains("C")); // <-- "C" is a StringView, avoiding allocation |
| 82 | //! [VectorMapSnippet] |
| 83 | return true; |
| 84 | } |
| 85 | |
| 86 | namespace SC |
| 87 | { |
nothing calls this directly
no test coverage detected