For the function to yield the expected result, the elements in the range shall already be ordered according to the same criterion (operator< or comp).
Unlike lower_bound, this function does not return an iterator to the element if it compares equivalent to value, but only if it compares strictly greater.
The behavior of this function template is equivalent to:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Parameters
- first, last
- Input iterators to the initial and final positions of the sequence to use. The range used is [first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.
- value
- Element value to be checked for its upper bound.
- comp
- Comparison function object that, taking two values of the same type than those contained in the range, returns true if the first argument goes before the second argument in the specific strict weak ordering it defines, and false otherwise.
Return value
Iterator to the upper bound position for value in the range.Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
Output:
lower_bound at position 3 upper_bound at position 6 |
Complexity
At most, logarithmic number of comparisons and linear number of steps in the length of [first,last).If used with random-access iterators, number of steps is reduced to logarithmic.
See also
| lower_bound | Return iterator to lower bound (function template) |
| equal_range | Get subrange of equal elements (function template) |
| binary_search | Test if value exists in sorted array (function template) |
| max_element | Return largest element in range (function template) |
