Let's say I wanted to construct an std::unordered_map<char, int>
to map the frequency of characters in a string. I would do something like
char* myString;
std::unordered_map<char, int> hashmap;
for(char* pch = myString; *pch !=0 ; pch++)
{
hashmap[*pch]++;
}
This, to me, feels dangerous as how do I know hashmap[*pch]++
will construct an integer in the value of the hashmap entry that starts at 0? Where do I find this guarantee (if it exists)?