Back to home page

EIC code displayed by LXR

 
 

    


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

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