File indexing completed on 2026-05-03 08:13:21
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LIBCPP___CXX03___ALGORITHM_RANGES_STABLE_PARTITION_H
0010 #define _LIBCPP___CXX03___ALGORITHM_RANGES_STABLE_PARTITION_H
0011
0012 #include <__cxx03/__algorithm/iterator_operations.h>
0013 #include <__cxx03/__algorithm/make_projected.h>
0014 #include <__cxx03/__algorithm/ranges_iterator_concept.h>
0015 #include <__cxx03/__algorithm/stable_partition.h>
0016 #include <__cxx03/__config>
0017 #include <__cxx03/__functional/identity.h>
0018 #include <__cxx03/__functional/invoke.h>
0019 #include <__cxx03/__functional/ranges_operations.h>
0020 #include <__cxx03/__iterator/concepts.h>
0021 #include <__cxx03/__iterator/iterator_traits.h>
0022 #include <__cxx03/__iterator/next.h>
0023 #include <__cxx03/__iterator/permutable.h>
0024 #include <__cxx03/__iterator/projected.h>
0025 #include <__cxx03/__ranges/access.h>
0026 #include <__cxx03/__ranges/concepts.h>
0027 #include <__cxx03/__ranges/dangling.h>
0028 #include <__cxx03/__ranges/subrange.h>
0029 #include <__cxx03/__type_traits/remove_cvref.h>
0030 #include <__cxx03/__utility/forward.h>
0031 #include <__cxx03/__utility/move.h>
0032
0033 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0034 # pragma GCC system_header
0035 #endif
0036
0037 _LIBCPP_PUSH_MACROS
0038 #include <__cxx03/__undef_macros>
0039
0040 #if _LIBCPP_STD_VER >= 20
0041
0042 _LIBCPP_BEGIN_NAMESPACE_STD
0043
0044 namespace ranges {
0045 namespace __stable_partition {
0046
0047 struct __fn {
0048 template <class _Iter, class _Sent, class _Proj, class _Pred>
0049 _LIBCPP_HIDE_FROM_ABI static subrange<__remove_cvref_t<_Iter>>
0050 __stable_partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {
0051 auto __last_iter = ranges::next(__first, __last);
0052
0053 auto&& __projected_pred = std::__make_projected(__pred, __proj);
0054 auto __result = std::__stable_partition<_RangeAlgPolicy>(
0055 std::move(__first), __last_iter, __projected_pred, __iterator_concept<_Iter>());
0056
0057 return {std::move(__result), std::move(__last_iter)};
0058 }
0059
0060 template <bidirectional_iterator _Iter,
0061 sentinel_for<_Iter> _Sent,
0062 class _Proj = identity,
0063 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
0064 requires permutable<_Iter>
0065 _LIBCPP_HIDE_FROM_ABI subrange<_Iter> operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
0066 return __stable_partition_fn_impl(__first, __last, __pred, __proj);
0067 }
0068
0069 template <bidirectional_range _Range,
0070 class _Proj = identity,
0071 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
0072 requires permutable<iterator_t<_Range>>
0073 _LIBCPP_HIDE_FROM_ABI borrowed_subrange_t<_Range>
0074 operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
0075 return __stable_partition_fn_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
0076 }
0077 };
0078
0079 }
0080
0081 inline namespace __cpo {
0082 inline constexpr auto stable_partition = __stable_partition::__fn{};
0083 }
0084 }
0085
0086 _LIBCPP_END_NAMESPACE_STD
0087
0088 #endif
0089
0090 _LIBCPP_POP_MACROS
0091
0092 #endif