Warning: This file is not a C or C++ file. It does not have highlighting.

1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_H
10#define _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/make_projected.h>
14#include <__algorithm/partial_sort.h>
15#include <__concepts/same_as.h>
16#include <__config>
17#include <__functional/identity.h>
18#include <__functional/invoke.h>
19#include <__functional/ranges_operations.h>
20#include <__iterator/concepts.h>
21#include <__iterator/iterator_traits.h>
22#include <__iterator/next.h>
23#include <__iterator/projected.h>
24#include <__iterator/sortable.h>
25#include <__ranges/access.h>
26#include <__ranges/concepts.h>
27#include <__ranges/dangling.h>
28#include <__utility/forward.h>
29#include <__utility/move.h>
30#include <__utility/pair.h>
31
32#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
33# pragma GCC system_header
34#endif
35
36_LIBCPP_PUSH_MACROS
37#include <__undef_macros>
38
39#if _LIBCPP_STD_VER >= 20
40
41_LIBCPP_BEGIN_NAMESPACE_STD
42
43namespace ranges {
44struct __partial_sort {
45 template <class _Iter, class _Sent, class _Comp, class _Proj>
46 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter
47 __partial_sort_fn_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp& __comp, _Proj& __proj) {
48 auto&& __projected_comp = std::__make_projected(__comp, __proj);
49 return std::__partial_sort<_RangeAlgPolicy>(std::move(__first), std::move(__middle), __last, __projected_comp);
50 }
51
52 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
53 requires sortable<_Iter, _Comp, _Proj>
54 _LIBCPP_HIDE_FROM_ABI constexpr _Iter
55 operator()(_Iter __first, _Iter __middle, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
56 return __partial_sort_fn_impl(std::move(__first), std::move(__middle), std::move(__last), __comp, __proj);
57 }
58
59 template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
60 requires sortable<iterator_t<_Range>, _Comp, _Proj>
61 _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
62 operator()(_Range&& __r, iterator_t<_Range> __middle, _Comp __comp = {}, _Proj __proj = {}) const {
63 return __partial_sort_fn_impl(ranges::begin(__r), std::move(__middle), ranges::end(__r), __comp, __proj);
64 }
65};
66
67inline namespace __cpo {
68inline constexpr auto partial_sort = __partial_sort{};
69} // namespace __cpo
70} // namespace ranges
71
72_LIBCPP_END_NAMESPACE_STD
73
74#endif // _LIBCPP_STD_VER >= 20
75
76_LIBCPP_POP_MACROS
77
78#endif // _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_H
79

Warning: This file is not a C or C++ file. It does not have highlighting.

source code of libcxx/include/__algorithm/ranges_partial_sort.h