function for finding last item less-than-or-equal to, like lower_bound
In a sorted container, the last element that is less than or equivalent to x, is the element before the first element that is greater than x. Thus you can call std::upper_bound, and decrement the returned iterator once. (Before decrementing, you must of course check that it is not the begin iterator; if it is, … Read more