std::is_partitioned

From Cppreference

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

template< class InputIterator, class UnaryPredicate >
bool is_partitioned( InputIterator first, InputIterator last, UnaryPredicate p );
(C++11 feature)

Returns true if all elements in the range [first, last) that satisfy the predicate p appear before all elements that don't. Also returns true if [first, last) is empty.

Contents

[edit] Parameters

first, last - the range of elements to check
p - unary predicate which returns ​true for the elements expected to be 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 InputIterator can be dereferenced and then implicitly converted to Type. ​

[edit] Return value

true if the range [first, last) is empty or is partitioned by p. false otherwise.

[edit] Complexity

At most std::distance(first, last) applications of p.

[edit] Equivalent function

[edit] Example

[edit] See also

partition
divides a range of elements into two groups
(function template)
partition_point (C++11)
locates the partition point of a partitioned range
(function template)