std::partition_point

From Cppreference

Jump to: navigation, search
Defined in header <algorithm>

template< class ForwardIterator, class UnaryPredicate >

ForwardIterator partition_point( ForwardIterator first, ForwardIterator last,

                                 UnaryPredicate p);
(1) (C++11 feature)

Examines the partitioned (as if by std::partition) range [first, last) and locates the end of the first partition, that is, the first element that does not satisfy p or last if last if all elements satisfy p.

Contents

[edit] Parameters

first, last - the partitioned range of elements to examine
p - unary predicate which returns ​true for the elements found in the beginning of the range.

The signature of the predicate function should be equivalent to the following:

bool pred(const Type &a);

The signature does not need to have const &, but the function must not modify the objects passed to it.
The type Type must be such that an object of type ForwardIterator can be dereferenced and then implicitly converted to Type. ​

[edit] Return value

The iterator past the end of the first partition within [first, last) or last if all elements satisfy p.

[edit] Complexity

Logarithmic in the distance between first and last

[edit] Example

[edit] See also

is_sorted (C++11)
checks whether a range is sorted into ascending order
(function template)