Is there a way the C++ STL Maps support this, since lower_bound and upper_bound on maps strictly return the value greater than the passed value.
Lower key
U
Your method will work, but you need to check to make sure you don't back over the beginning of the map. Plus you need lower_bound, not upper_bound.
iterator = map.lower_bound(2.3) if (iterator != map.begin()) --iterator;