Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:11

0001 //===----------------------------------------------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef _LIBCPP___ALGORITHM_RANGES_STABLE_PARTITION_H
0010 #define _LIBCPP___ALGORITHM_RANGES_STABLE_PARTITION_H
0011 
0012 #include <__algorithm/iterator_operations.h>
0013 #include <__algorithm/make_projected.h>
0014 #include <__algorithm/ranges_iterator_concept.h>
0015 #include <__algorithm/stable_partition.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/permutable.h>
0024 #include <__iterator/projected.h>
0025 #include <__ranges/access.h>
0026 #include <__ranges/concepts.h>
0027 #include <__ranges/dangling.h>
0028 #include <__ranges/subrange.h>
0029 #include <__type_traits/remove_cvref.h>
0030 #include <__utility/forward.h>
0031 #include <__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 <__undef_macros>
0039 
0040 #if _LIBCPP_STD_VER >= 20
0041 
0042 _LIBCPP_BEGIN_NAMESPACE_STD
0043 
0044 namespace ranges {
0045 struct __stable_partition {
0046   template <class _Iter, class _Sent, class _Proj, class _Pred>
0047   _LIBCPP_HIDE_FROM_ABI static subrange<__remove_cvref_t<_Iter>>
0048   __stable_partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {
0049     auto __last_iter = ranges::next(__first, __last);
0050 
0051     auto&& __projected_pred = std::__make_projected(__pred, __proj);
0052     auto __result           = std::__stable_partition<_RangeAlgPolicy>(
0053         std::move(__first), __last_iter, __projected_pred, __iterator_concept<_Iter>());
0054 
0055     return {std::move(__result), std::move(__last_iter)};
0056   }
0057 
0058   template <bidirectional_iterator _Iter,
0059             sentinel_for<_Iter> _Sent,
0060             class _Proj = identity,
0061             indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
0062     requires permutable<_Iter>
0063   _LIBCPP_HIDE_FROM_ABI subrange<_Iter> operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
0064     return __stable_partition_fn_impl(__first, __last, __pred, __proj);
0065   }
0066 
0067   template <bidirectional_range _Range,
0068             class _Proj = identity,
0069             indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
0070     requires permutable<iterator_t<_Range>>
0071   _LIBCPP_HIDE_FROM_ABI borrowed_subrange_t<_Range>
0072   operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
0073     return __stable_partition_fn_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
0074   }
0075 };
0076 
0077 inline namespace __cpo {
0078 inline constexpr auto stable_partition = __stable_partition{};
0079 } // namespace __cpo
0080 } // namespace ranges
0081 
0082 _LIBCPP_END_NAMESPACE_STD
0083 
0084 #endif // _LIBCPP_STD_VER >= 20
0085 
0086 _LIBCPP_POP_MACROS
0087 
0088 #endif // _LIBCPP___ALGORITHM_RANGES_STABLE_PARTITION_H