partition

Prototype

Description

Partition reorders the elements in the range [first, last) based
on the function objectpred, such that
the elements that satisfy pred precede the elements
that fail to satisfy it. The postcondition is that, for some
iterator middle in the range [first, last),
pred(*i) is true for every iterator i in the range [first, middle) and
false for every iterator i in the range [middle, last). [1]
The return value of partition is middle.

Definition

Defined in the standard header algorithm, and in the nonstandard
backward-compatibility header algo.h.

Notes

[1]
The relative order of elements in these two blocks is not necessarily
the same as it was in the original sequence. A different algorithm,
stable_partition, does guarantee to preserve the relative order.