[rtsan] Remove mkfifoat interceptor (#116997)
[llvm-project.git] / libcxx / include / __algorithm / ranges_stable_sort.h
blob9c7df80ae98722d906957c98c9746fcf88c8e002
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_STABLE_SORT_H
10 #define _LIBCPP___ALGORITHM_RANGES_STABLE_SORT_H
12 #include <__algorithm/iterator_operations.h>
13 #include <__algorithm/make_projected.h>
14 #include <__algorithm/stable_sort.h>
15 #include <__config>
16 #include <__functional/identity.h>
17 #include <__functional/invoke.h>
18 #include <__functional/ranges_operations.h>
19 #include <__iterator/concepts.h>
20 #include <__iterator/iterator_traits.h>
21 #include <__iterator/next.h>
22 #include <__iterator/projected.h>
23 #include <__iterator/sortable.h>
24 #include <__ranges/access.h>
25 #include <__ranges/concepts.h>
26 #include <__ranges/dangling.h>
27 #include <__utility/forward.h>
28 #include <__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 <__undef_macros>
37 #if _LIBCPP_STD_VER >= 20
39 _LIBCPP_BEGIN_NAMESPACE_STD
41 namespace ranges {
42 struct __stable_sort {
43 template <class _Iter, class _Sent, class _Comp, class _Proj>
44 _LIBCPP_HIDE_FROM_ABI static _Iter __stable_sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
45 auto __last_iter = ranges::next(__first, __last);
47 auto&& __projected_comp = std::__make_projected(__comp, __proj);
48 std::__stable_sort_impl<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
50 return __last_iter;
53 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
54 requires sortable<_Iter, _Comp, _Proj>
55 _LIBCPP_HIDE_FROM_ABI _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
56 return __stable_sort_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
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 borrowed_iterator_t<_Range>
62 operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
63 return __stable_sort_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
67 inline namespace __cpo {
68 inline constexpr auto stable_sort = __stable_sort{};
69 } // namespace __cpo
70 } // namespace ranges
72 _LIBCPP_END_NAMESPACE_STD
74 #endif // _LIBCPP_STD_VER >= 20
76 _LIBCPP_POP_MACROS
78 #endif // _LIBCPP___ALGORITHM_RANGES_STABLE_SORT_H