The worst bugs (C++)

The worst bugs (C++)

The set, multiset, unordered_set and unordered_multiset have const iterators only, and map, multimap, unordered_map and unordered_multimap have their keys const.Now, back to our code, how to fix it? Something like this:
std::mapstd::string, int container = {
{ “one”, 1 },
{ “five”, 2},
{ “three”, 3 }
};
auto it = container.find(“five”);
if (it ! = container.end()) {
= “two”;
}At that time, it was practically impossible to change the whole container: it was not so local and it had to stay a map.

Source: medium.com