25 Algorithms library [algorithms]

25.7 Sorting and related operations [alg.sorting]

25.7.1 Sorting [alg.sort]

25.7.1.3 partial_­sort [partial.sort]

template<class RandomAccessIterator> constexpr void partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last); template<class ExecutionPolicy, class RandomAccessIterator> void partial_sort(ExecutionPolicy&& exec, RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last); template<class RandomAccessIterator, class Compare> constexpr void partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp); template<class ExecutionPolicy, class RandomAccessIterator, class Compare> void partial_sort(ExecutionPolicy&& exec, RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp); template<RandomAccessIterator I, Sentinel<I> S, class Comp = ranges::less, class Proj = identity> requires Sortable<I, Comp, Proj> constexpr I ranges::partial_sort(I first, I middle, S last, Comp comp = {}, Proj proj = {});
Let comp be less{} and proj be identity{} for the overloads with no parameters by those names.
Requires: [first, middle) and [middle, last) shall be valid ranges.
For the overloads in namespace std, RandomAccessIterator shall meet the Cpp17ValueSwappable requirements ([swappable.requirements]) and the type of *first shall meet the Cpp17MoveConstructible ([tab:moveconstructible]Table *tab:moveconstructible) and Cpp17MoveAssignable ([tab:moveassignable]Table *tab:moveassignable) requirements.
Effects: Places the first middle - first elements from the range [first, last) as sorted with respect to comp and proj into the range [first, middle).
The rest of the elements in the range [middle, last) are placed in an unspecified order.
Returns: last for the overload in namespace ranges.
Complexity: Approximately (last - first) * log(middle - first) comparisons, and twice as many projections.
template<RandomAccessRange R, class Comp = ranges::less, class Proj = identity> requires Sortable<iterator_t<R>, Comp, Proj> constexpr safe_iterator_t<R> ranges::partial_sort(R&& r, iterator_t<R> middle, Comp comp = {}, Proj proj = {});
Effects: Equivalent to:
return ranges::partial_sort(ranges::begin(r), middle, ranges::end(r), comp, proj);