The square bracket operator in associative containers (map, unordered map) will insert an element in the map if it doesn't exist. In case the mapped value is an integer, like
std::map<std::string, int> map; // Or std::unordered_map
is calling the pre-increment operator well defined even in the case []
triggers the insertion of a new element?
I'm suspecting it should be ok, since in both ordered and unordered maps the standard mandates that a new element of type T
is inserted as T()
i.e. value initialization which means that the number zero is inserted.