C ++ - How to tell if there is no return value from map :: upper_bound ()?
I have a very simple map:
std::map<int, double> distances;
distances[20.5] = 1;
distances[19] = 2;
distances[24] = 3;
How do I know if there is no return value when using map :: upper_bound () in this case, for example:
std::map<int, double>::iterator iter = distances.upper_bound(24);
(24 is the maximum key, so an unexpected result is returned, but how do I know with the code? How do I know I have reached the maximum key?).
Thanks!
+1
a source to share
3 answers