Standard C++ Library Reference ISO/IEC (VERSION3)
If dest and first designate regions of storage, the range [dest, dest + (last -
first)) must not overlap the range [first, last).
The second template function behaves the same, except that it executes the statement:
if (N == 0 || !pred(*(first + N), V))
V = *(first + N), *dest++ = V;
upper_bound
template<class FwdIt, class Ty>
FwdIt upper_bound(FwdIt first, FwdIt last,
const Ty& val);
template<class FwdIt, class Ty, class Pr>
FwdIt upper_bound(FwdIt first, FwdIt last,
const Ty& val, Pr pred);
The first template function determines the highest value of N in the range (0, last -
first] such that, for each M in the range [0, N) the predicate !(val < *(first +
M)) is true, where the elements designated by iterators in the range [first, last) form a
sequence ordered by operator<. It then returns first + N. Thus, the function determines
the highest position before which val can be inserted in the sequence and still preserve its
ordering.
The function evaluates the ordering predicate X < Y at most ceil(log(last - first))
+ 1 times.
The second template function behaves the same, except that it replaces operator<(X, Y)
with pred(X, Y).
See also the Table of Contents and the Index.
Copyright © 1994-2001 by P.J. Plauger. Portions derived from work copyright © 1994 by
Hewlett-Packard Company. All rights reserved.