In the implementation, std::map::operator[]you will see that if the element is not found in the index, a new one is inserted and returned:
ReturnValue = this->insert(where, make_pair(key_value, mapped_type()));
where mapped_typeis the second type, in your case int. So yes, it is initialized by default 0since it is inserted as mapped_type().
source
share