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