Subtle insertion bug with std::map

If you try to access an element in a std::map using a key that doesn't exist already in the map, it will insert a default-constructed value with that key. This will lead to unexpected behavior if you're not aware that the insertion has occurred.

std::map<int, std::string> cities;
myMap[0] = "Rome";

//inserts default-constructed value "" with key 1
std::string value = myMap[1]; 

//outputs empty string ""
std::cout << value << std::endl;