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 //===----------------------------------------------------------------------===// 8 9 #ifndef _LIBCPP___ALGORITHM_PSTL_IS_PARITTIONED 10 #define _LIBCPP___ALGORITHM_PSTL_IS_PARITTIONED 11 12 #include <__algorithm/pstl_any_all_none_of.h> 13 #include <__algorithm/pstl_backend.h> 14 #include <__algorithm/pstl_find.h> 15 #include <__algorithm/pstl_frontend_dispatch.h> 16 #include <__config> 17 #include <__type_traits/enable_if.h> 18 #include <__type_traits/is_execution_policy.h> 19 #include <__type_traits/remove_cvref.h> 20 #include <__utility/move.h> 21 22 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 23 # pragma GCC system_header 24 #endif 25 26 #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 27 28 _LIBCPP_BEGIN_NAMESPACE_STD 29 30 template <class> 31 void __pstl_is_partitioned(); 32 33 template <class _ExecutionPolicy, 34 class _ForwardIterator, 35 class _Predicate, 36 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, 37 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> 38 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool 39 is_partitioned(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { 40 return std::__pstl_frontend_dispatch( 41 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_is_partitioned), 42 [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _Predicate __g_pred) { 43 __g_first = std::find_if_not(__policy, __g_first, __g_last, __g_pred); 44 if (__g_first == __g_last) 45 return true; 46 ++__g_first; 47 return std::none_of(__policy, __g_first, __g_last, __g_pred); 48 }, 49 std::move(__first), 50 std::move(__last), 51 std::move(__pred)); 52 } 53 54 _LIBCPP_END_NAMESPACE_STD 55 56 #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 57 58 #endif // _LIBCPP___ALGORITHM_PSTL_IS_PARITTIONED 59