I saw a sample code similar to the following:
std::string s = "Hello World!"; std::map<char, std::size_t> h; for (std::string::const_iterator i=s.cbegin(); i!=s.cend(); ++i) { ++h[*i]; } assert(h['l'] == 3);
This, apparently, relies on the fact that the type of the value is reset to zero at the first occurrence of each letter. Is this guaranteed even when using something like std::size_t , which does not have a default constructor, resetting it to zero?
source share