After writing:
std::pair<int, int> x;
Am I guaranteed that x.first and x.second are both zero? Or could they have any value?
The reason why I care is because I'm trying to determine whether a map whose values are pointers is guaranteed to return NULL if I access an element that's not in the map. I.e., if I do:
std::map<int, void*> my_map;
std::cout << int(my_map[5]) << std::endl;
then am I guaranteed to get zero (NULL)? Or is the behavior undefined?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…