cpp/algorithm/lower bound

Returns an iterator pointing to the first element in the range that does not satisfy  (or ), (i.e. greater or equal to), or  if no such element is found.

The range must be partitioned with respect to the expression  (or ), i.e., all elements for which the expression is  must precede all elements for which the expression is. A fully-sorted range meets this criterion.

The first version uses to compare the elements, the second version uses the given comparison function.

Return value
Iterator pointing to the first element in the range such that  (or ) is false, or  if no such element is found.

Complexity
The number of comparisons performed is logarithmic in the distance between and  (at most $log 2(last - first) + O(1)$ comparisons). However, for non-s, the number of iterator increments is linear. Notably, std, std, std, and std iterators are not random access, and so their member functions should be preferred.

Possible implementation
See also the implementations in libstdc++ and libc++.