Maps have been improved quite a bit.
For example, if you have a std::map<std::string, int>, you can iterate over it like this:
for (auto [s, n]: my_map) {
// s = string key, n = int value
}
You can test for membership: if (my_map.contains(“foo”)) { /* do something * }
Although I still usually use find because if the key is in the map, I probably want the value.You can use initialization lists with them too:
std::map<std::string, int> my_map = {
{ “one”, 1 },
{ “two”, 2 },
{ “three”, 3 }
};