DESCRIPTION

The upper_bound algorithm is one of a set of binary search
algorithms. All of these algorithms perform binary searches
on ordered containers. Each algorithm has two versions. The
first version uses the less than operator (operator<) to
perform the comparison, and assumes that the sequence has
been sorted using that operator. The second version allows
you to include a function object of type Compare, and
assumes that Compare is the function used to sort the
sequence. The function object must be a binary predicate.
The upper_bound algorithm finds the last position in a con-
tainer that value can occupy without violating the
container's ordering. upper_bound's return value is the
iterator for the first element in the container that is
greater than value, or, when the comparison operator is
used, the first element that does NOT satisfy the comparison
function. Because the algorithm is restricted to using the
less than operator or the user-defined function to perform
the search, upper_bound returns an iterator i in the range
[first, last) such that for any iterator j in the range
[first, i) the appropriate version of the following condi-
tions holds:
!(value < *j)
or
comp(value, *j) == false

WARNINGS

If your compiler does not support default template parame-
ters, then you always need to supply the Allocator template
argument. For instance, you need to write:
vector<int, allocator<int> >
instead of:
vector<int>
If your compiler does not support namespaces, then you do
not need the using declaration for std.