Is it a feature of unordered_map::find() to insert the key that we lookup with 0 value automatically?
Let me make this clear
unordered_map<int, int> tempMap;
//some code
if(tempMap.find(1) == tempMap.end()){
//do something but not insert the 1 with a corresponding value into the tempMap
}
so if I lookup 1 again, will it be there in the tempMap having 0 as corresponding value.
Is that a feature of unordered_map?
No,
findonly searches and returns an iterator.That said,
std::unordered_map(andstd::map) both overloadoperator[]which will insert a default if needed: