multimap offers the methods lower_bound and upper_bound. Both may return an iterator to a value with key greater than the desired, with lower_bound possibly yielding exactly the desired.
Now I want an iterator to a value where the key is strictly less the requested. If it were a map rather than multimap, this would be relatively simple to achieve as described here:
Returning the greatest key strictly less than the given key in a C++ Map.
But in a multimap, decrementing an iterator is not guaranteed to make it point to a strictly smaller key. So I would need to decrement repeatedly, until a smaller key is found. Not particularly nice.
Is there a more elegant way of doing this?
The keys will in general be floating-point.
My apologies, it turns out that you can actually do it with a single decrement. I just placed it wrong in my program, that was the real error.
lower_boundpoints to the smallest element greater than or equal to the argument (orend). Thus decrementing it once gives you the desired element (if it exists).