Partial_sort_copy is an overloaded name; there are actually two partial_sort_copy
functions.
template <class InputIterator, class RandomAccessIterator>
RandomAccessIterator
partial_sort_copy(InputIterator first, InputIterator last,
RandomAccessIterator result_first,
RandomAccessIterator result_last);
template <class InputIterator, class RandomAccessIterator,
class StrictWeakOrdering>
RandomAccessIterator
partial_sort_copy(InputIterator first, InputIterator last,
RandomAccessIterator result_first,
RandomAccessIterator result_last, Compare comp);
Description
Partial_sort_copy copies the smallest N elements from the range
[first, last) to the range [result_first, result_first + N), where
N is the smaller of last - first and result_last - result_first.
The elements in [result_first, result_first + N) will be in ascending
order.
The two versions of partial_sort_copy differ in how they define whether one
element is less than another. The first version compares
objects using operator<, and the second compares objects using
a function objectcomp.
The postcondition for the first version of partial_sort_copy is as follows.
If i and j are
any two valid iterators in the range [result_first, result_first +
N) such that i precedes j, then *j < *i will be false.
The corresponding postcondition for the second version is that
comp(*j, *i) will be false.