[rtsan] Remove mkfifoat interceptor (#116997)
[llvm-project.git] / libcxx / include / __cxx03 / __algorithm / ranges_stable_partition.h
blobcd4ae07bf9c7050b8857e5a3b1e8c0baaa11901e
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_PARTITION_H
10 #define _LIBCPP___ALGORITHM_RANGES_STABLE_PARTITION_H
12 #include <__cxx03/__algorithm/iterator_operations.h>
13 #include <__cxx03/__algorithm/make_projected.h>
14 #include <__cxx03/__algorithm/ranges_iterator_concept.h>
15 #include <__cxx03/__algorithm/stable_partition.h>
16 #include <__cxx03/__config>
17 #include <__cxx03/__functional/identity.h>
18 #include <__cxx03/__functional/invoke.h>
19 #include <__cxx03/__functional/ranges_operations.h>
20 #include <__cxx03/__iterator/concepts.h>
21 #include <__cxx03/__iterator/iterator_traits.h>
22 #include <__cxx03/__iterator/next.h>
23 #include <__cxx03/__iterator/permutable.h>
24 #include <__cxx03/__iterator/projected.h>
25 #include <__cxx03/__ranges/access.h>
26 #include <__cxx03/__ranges/concepts.h>
27 #include <__cxx03/__ranges/dangling.h>
28 #include <__cxx03/__ranges/subrange.h>
29 #include <__cxx03/__type_traits/remove_cvref.h>
30 #include <__cxx03/__utility/forward.h>
31 #include <__cxx03/__utility/move.h>
33 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
34 # pragma GCC system_header
35 #endif
37 _LIBCPP_PUSH_MACROS
38 #include <__cxx03/__undef_macros>
40 #if _LIBCPP_STD_VER >= 20
42 _LIBCPP_BEGIN_NAMESPACE_STD
44 namespace ranges {
45 namespace __stable_partition {
47 struct __fn {
48 template <class _Iter, class _Sent, class _Proj, class _Pred>
49 _LIBCPP_HIDE_FROM_ABI static subrange<__remove_cvref_t<_Iter>>
50 __stable_partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {
51 auto __last_iter = ranges::next(__first, __last);
53 auto&& __projected_pred = std::__make_projected(__pred, __proj);
54 auto __result = std::__stable_partition<_RangeAlgPolicy>(
55 std::move(__first), __last_iter, __projected_pred, __iterator_concept<_Iter>());
57 return {std::move(__result), std::move(__last_iter)};
60 template <bidirectional_iterator _Iter,
61 sentinel_for<_Iter> _Sent,
62 class _Proj = identity,
63 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
64 requires permutable<_Iter>
65 _LIBCPP_HIDE_FROM_ABI subrange<_Iter> operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
66 return __stable_partition_fn_impl(__first, __last, __pred, __proj);
69 template <bidirectional_range _Range,
70 class _Proj = identity,
71 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
72 requires permutable<iterator_t<_Range>>
73 _LIBCPP_HIDE_FROM_ABI borrowed_subrange_t<_Range>
74 operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
75 return __stable_partition_fn_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
79 } // namespace __stable_partition
81 inline namespace __cpo {
82 inline constexpr auto stable_partition = __stable_partition::__fn{};
83 } // namespace __cpo
84 } // namespace ranges
86 _LIBCPP_END_NAMESPACE_STD
88 #endif // _LIBCPP_STD_VER >= 20
90 _LIBCPP_POP_MACROS
92 #endif // _LIBCPP___ALGORITHM_RANGES_STABLE_PARTITION_H