File indexing completed on 2026-05-03 08:13:10
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_H
0010 #define _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_H
0011
0012 #include <__algorithm/iterator_operations.h>
0013 #include <__algorithm/make_projected.h>
0014 #include <__algorithm/partial_sort.h>
0015 #include <__concepts/same_as.h>
0016 #include <__config>
0017 #include <__functional/identity.h>
0018 #include <__functional/invoke.h>
0019 #include <__functional/ranges_operations.h>
0020 #include <__iterator/concepts.h>
0021 #include <__iterator/iterator_traits.h>
0022 #include <__iterator/next.h>
0023 #include <__iterator/projected.h>
0024 #include <__iterator/sortable.h>
0025 #include <__ranges/access.h>
0026 #include <__ranges/concepts.h>
0027 #include <__ranges/dangling.h>
0028 #include <__utility/forward.h>
0029 #include <__utility/move.h>
0030 #include <__utility/pair.h>
0031
0032 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0033 # pragma GCC system_header
0034 #endif
0035
0036 _LIBCPP_PUSH_MACROS
0037 #include <__undef_macros>
0038
0039 #if _LIBCPP_STD_VER >= 20
0040
0041 _LIBCPP_BEGIN_NAMESPACE_STD
0042
0043 namespace ranges {
0044 struct __partial_sort {
0045 template <class _Iter, class _Sent, class _Comp, class _Proj>
0046 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter
0047 __partial_sort_fn_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp& __comp, _Proj& __proj) {
0048 auto&& __projected_comp = std::__make_projected(__comp, __proj);
0049 return std::__partial_sort<_RangeAlgPolicy>(std::move(__first), std::move(__middle), __last, __projected_comp);
0050 }
0051
0052 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
0053 requires sortable<_Iter, _Comp, _Proj>
0054 _LIBCPP_HIDE_FROM_ABI constexpr _Iter
0055 operator()(_Iter __first, _Iter __middle, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
0056 return __partial_sort_fn_impl(std::move(__first), std::move(__middle), std::move(__last), __comp, __proj);
0057 }
0058
0059 template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
0060 requires sortable<iterator_t<_Range>, _Comp, _Proj>
0061 _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
0062 operator()(_Range&& __r, iterator_t<_Range> __middle, _Comp __comp = {}, _Proj __proj = {}) const {
0063 return __partial_sort_fn_impl(ranges::begin(__r), std::move(__middle), ranges::end(__r), __comp, __proj);
0064 }
0065 };
0066
0067 inline namespace __cpo {
0068 inline constexpr auto partial_sort = __partial_sort{};
0069 }
0070 }
0071
0072 _LIBCPP_END_NAMESPACE_STD
0073
0074 #endif
0075
0076 _LIBCPP_POP_MACROS
0077
0078 #endif