[rtsan] Remove mkfifoat interceptor (#116997)
[llvm-project.git] / libcxx / include / __cxx03 / __algorithm / ranges_nth_element.h
blobdf428390f7a3d226349592587c23ce380088cf95
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 //===----------------------------------------------------------------------===//
9 #ifndef _LIBCPP___ALGORITHM_RANGES_NTH_ELEMENT_H
10 #define _LIBCPP___ALGORITHM_RANGES_NTH_ELEMENT_H
12 #include <__cxx03/__algorithm/iterator_operations.h>
13 #include <__cxx03/__algorithm/make_projected.h>
14 #include <__cxx03/__algorithm/nth_element.h>
15 #include <__cxx03/__config>
16 #include <__cxx03/__functional/identity.h>
17 #include <__cxx03/__functional/invoke.h>
18 #include <__cxx03/__functional/ranges_operations.h>
19 #include <__cxx03/__iterator/concepts.h>
20 #include <__cxx03/__iterator/iterator_traits.h>
21 #include <__cxx03/__iterator/next.h>
22 #include <__cxx03/__iterator/projected.h>
23 #include <__cxx03/__iterator/sortable.h>
24 #include <__cxx03/__ranges/access.h>
25 #include <__cxx03/__ranges/concepts.h>
26 #include <__cxx03/__ranges/dangling.h>
27 #include <__cxx03/__utility/forward.h>
28 #include <__cxx03/__utility/move.h>
30 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
31 # pragma GCC system_header
32 #endif
34 _LIBCPP_PUSH_MACROS
35 #include <__cxx03/__undef_macros>
37 #if _LIBCPP_STD_VER >= 20
39 _LIBCPP_BEGIN_NAMESPACE_STD
41 namespace ranges {
42 namespace __nth_element {
44 struct __fn {
45 template <class _Iter, class _Sent, class _Comp, class _Proj>
46 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter
47 __nth_element_fn_impl(_Iter __first, _Iter __nth, _Sent __last, _Comp& __comp, _Proj& __proj) {
48 auto __last_iter = ranges::next(__first, __last);
50 auto&& __projected_comp = std::__make_projected(__comp, __proj);
51 std::__nth_element_impl<_RangeAlgPolicy>(std::move(__first), std::move(__nth), __last_iter, __projected_comp);
53 return __last_iter;
56 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
57 requires sortable<_Iter, _Comp, _Proj>
58 _LIBCPP_HIDE_FROM_ABI constexpr _Iter
59 operator()(_Iter __first, _Iter __nth, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
60 return __nth_element_fn_impl(std::move(__first), std::move(__nth), std::move(__last), __comp, __proj);
63 template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
64 requires sortable<iterator_t<_Range>, _Comp, _Proj>
65 _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
66 operator()(_Range&& __r, iterator_t<_Range> __nth, _Comp __comp = {}, _Proj __proj = {}) const {
67 return __nth_element_fn_impl(ranges::begin(__r), std::move(__nth), ranges::end(__r), __comp, __proj);
71 } // namespace __nth_element
73 inline namespace __cpo {
74 inline constexpr auto nth_element = __nth_element::__fn{};
75 } // namespace __cpo
76 } // namespace ranges
78 _LIBCPP_END_NAMESPACE_STD
80 #endif // _LIBCPP_STD_VER >= 20
82 _LIBCPP_POP_MACROS
84 #endif // _LIBCPP___ALGORITHM_RANGES_NTH_ELEMENT_H