5,321
edits
No edit summary |
|||
Line 592: | Line 592: | ||
<syntaxhighlight lang="C++"> | <syntaxhighlight lang="C++"> | ||
std::unordered_map<int, std::string> my_map; | std::unordered_map<int, std::string> my_map; | ||
my_map.insert(5, "hey"); | my_map[5] = "hey"; // Fine as long as value is not a reference. | ||
my_map.insert({5, "hey"}); // Necessary if value is a reference. | |||
my_map.find(5) != my_map.end(); | my_map.find(5) != my_map.end(); | ||
my_map.contains(5); // C++20 | my_map.contains(5); // C++20 |