xref: /freebsd-src/contrib/llvm-project/libcxx/include/__algorithm/pstl.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1*0fca6ea1SDimitry Andric //===----------------------------------------------------------------------===//
2*0fca6ea1SDimitry Andric //
3*0fca6ea1SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0fca6ea1SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*0fca6ea1SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0fca6ea1SDimitry Andric //
7*0fca6ea1SDimitry Andric //===----------------------------------------------------------------------===//
8*0fca6ea1SDimitry Andric 
9*0fca6ea1SDimitry Andric #ifndef _LIBCPP___ALGORITHM_PSTL_H
10*0fca6ea1SDimitry Andric #define _LIBCPP___ALGORITHM_PSTL_H
11*0fca6ea1SDimitry Andric 
12*0fca6ea1SDimitry Andric #include <__config>
13*0fca6ea1SDimitry Andric 
14*0fca6ea1SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15*0fca6ea1SDimitry Andric #  pragma GCC system_header
16*0fca6ea1SDimitry Andric #endif
17*0fca6ea1SDimitry Andric 
18*0fca6ea1SDimitry Andric _LIBCPP_PUSH_MACROS
19*0fca6ea1SDimitry Andric #include <__undef_macros>
20*0fca6ea1SDimitry Andric 
21*0fca6ea1SDimitry Andric #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
22*0fca6ea1SDimitry Andric 
23*0fca6ea1SDimitry Andric #  include <__functional/operations.h>
24*0fca6ea1SDimitry Andric #  include <__iterator/cpp17_iterator_concepts.h>
25*0fca6ea1SDimitry Andric #  include <__iterator/iterator_traits.h>
26*0fca6ea1SDimitry Andric #  include <__pstl/backend.h>
27*0fca6ea1SDimitry Andric #  include <__pstl/dispatch.h>
28*0fca6ea1SDimitry Andric #  include <__pstl/handle_exception.h>
29*0fca6ea1SDimitry Andric #  include <__type_traits/enable_if.h>
30*0fca6ea1SDimitry Andric #  include <__type_traits/is_execution_policy.h>
31*0fca6ea1SDimitry Andric #  include <__type_traits/remove_cvref.h>
32*0fca6ea1SDimitry Andric #  include <__utility/forward.h>
33*0fca6ea1SDimitry Andric #  include <__utility/move.h>
34*0fca6ea1SDimitry Andric 
35*0fca6ea1SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
36*0fca6ea1SDimitry Andric 
37*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
38*0fca6ea1SDimitry Andric           class _ForwardIterator,
39*0fca6ea1SDimitry Andric           class _Predicate,
40*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
41*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
42*0fca6ea1SDimitry Andric [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool
43*0fca6ea1SDimitry Andric any_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
44*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "any_of requires a ForwardIterator");
45*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__any_of, __pstl::__current_configuration, _RawPolicy>;
46*0fca6ea1SDimitry Andric   return __pstl::__handle_exception<_Implementation>(
47*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred));
48*0fca6ea1SDimitry Andric }
49*0fca6ea1SDimitry Andric 
50*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
51*0fca6ea1SDimitry Andric           class _ForwardIterator,
52*0fca6ea1SDimitry Andric           class _Pred,
53*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
54*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
55*0fca6ea1SDimitry Andric [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool
56*0fca6ea1SDimitry Andric all_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) {
57*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "all_of requires a ForwardIterator");
58*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__all_of, __pstl::__current_configuration, _RawPolicy>;
59*0fca6ea1SDimitry Andric   return __pstl::__handle_exception<_Implementation>(
60*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred));
61*0fca6ea1SDimitry Andric }
62*0fca6ea1SDimitry Andric 
63*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
64*0fca6ea1SDimitry Andric           class _ForwardIterator,
65*0fca6ea1SDimitry Andric           class _Pred,
66*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
67*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
68*0fca6ea1SDimitry Andric [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool
69*0fca6ea1SDimitry Andric none_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) {
70*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "none_of requires a ForwardIterator");
71*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__none_of, __pstl::__current_configuration, _RawPolicy>;
72*0fca6ea1SDimitry Andric   return __pstl::__handle_exception<_Implementation>(
73*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred));
74*0fca6ea1SDimitry Andric }
75*0fca6ea1SDimitry Andric 
76*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
77*0fca6ea1SDimitry Andric           class _ForwardIterator,
78*0fca6ea1SDimitry Andric           class _ForwardOutIterator,
79*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
80*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
81*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator
82*0fca6ea1SDimitry Andric copy(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _ForwardOutIterator __result) {
83*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(
84*0fca6ea1SDimitry Andric       _ForwardIterator, "copy(first, last, result) requires [first, last) to be ForwardIterators");
85*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(
86*0fca6ea1SDimitry Andric       _ForwardOutIterator, "copy(first, last, result) requires result to be a ForwardIterator");
87*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(
88*0fca6ea1SDimitry Andric       _ForwardOutIterator, decltype(*__first), "copy(first, last, result) requires result to be an OutputIterator");
89*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__copy, __pstl::__current_configuration, _RawPolicy>;
90*0fca6ea1SDimitry Andric   return __pstl::__handle_exception<_Implementation>(
91*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__result));
92*0fca6ea1SDimitry Andric }
93*0fca6ea1SDimitry Andric 
94*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
95*0fca6ea1SDimitry Andric           class _ForwardIterator,
96*0fca6ea1SDimitry Andric           class _ForwardOutIterator,
97*0fca6ea1SDimitry Andric           class _Size,
98*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
99*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
100*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator
101*0fca6ea1SDimitry Andric copy_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n, _ForwardOutIterator __result) {
102*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(
103*0fca6ea1SDimitry Andric       _ForwardIterator, "copy_n(first, n, result) requires first to be a ForwardIterator");
104*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(
105*0fca6ea1SDimitry Andric       _ForwardOutIterator, "copy_n(first, n, result) requires result to be a ForwardIterator");
106*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(
107*0fca6ea1SDimitry Andric       _ForwardOutIterator, decltype(*__first), "copy_n(first, n, result) requires result to be an OutputIterator");
108*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__copy_n, __pstl::__current_configuration, _RawPolicy>;
109*0fca6ea1SDimitry Andric   return __pstl::__handle_exception<_Implementation>(
110*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__n), std::move(__result));
111*0fca6ea1SDimitry Andric }
112*0fca6ea1SDimitry Andric 
113*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
114*0fca6ea1SDimitry Andric           class _ForwardIterator,
115*0fca6ea1SDimitry Andric           class _Predicate,
116*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
117*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
118*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator>
119*0fca6ea1SDimitry Andric count_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
120*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(
121*0fca6ea1SDimitry Andric       _ForwardIterator, "count_if(first, last, pred) requires [first, last) to be ForwardIterators");
122*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__count_if, __pstl::__current_configuration, _RawPolicy>;
123*0fca6ea1SDimitry Andric   return __pstl::__handle_exception<_Implementation>(
124*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred));
125*0fca6ea1SDimitry Andric }
126*0fca6ea1SDimitry Andric 
127*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
128*0fca6ea1SDimitry Andric           class _ForwardIterator,
129*0fca6ea1SDimitry Andric           class _Tp,
130*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
131*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
132*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator>
133*0fca6ea1SDimitry Andric count(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
134*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(
135*0fca6ea1SDimitry Andric       _ForwardIterator, "count(first, last, val) requires [first, last) to be ForwardIterators");
136*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__count, __pstl::__current_configuration, _RawPolicy>;
137*0fca6ea1SDimitry Andric   return __pstl::__handle_exception<_Implementation>(
138*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), __value);
139*0fca6ea1SDimitry Andric }
140*0fca6ea1SDimitry Andric 
141*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
142*0fca6ea1SDimitry Andric           class _ForwardIterator1,
143*0fca6ea1SDimitry Andric           class _ForwardIterator2,
144*0fca6ea1SDimitry Andric           class _Pred,
145*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
146*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
147*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI bool
148*0fca6ea1SDimitry Andric equal(_ExecutionPolicy&& __policy,
149*0fca6ea1SDimitry Andric       _ForwardIterator1 __first1,
150*0fca6ea1SDimitry Andric       _ForwardIterator1 __last1,
151*0fca6ea1SDimitry Andric       _ForwardIterator2 __first2,
152*0fca6ea1SDimitry Andric       _Pred __pred) {
153*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "equal requires ForwardIterators");
154*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "equal requires ForwardIterators");
155*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__equal_3leg, __pstl::__current_configuration, _RawPolicy>;
156*0fca6ea1SDimitry Andric   return __pstl::__handle_exception<_Implementation>(
157*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy),
158*0fca6ea1SDimitry Andric       std::move(__first1),
159*0fca6ea1SDimitry Andric       std::move(__last1),
160*0fca6ea1SDimitry Andric       std::move(__first2),
161*0fca6ea1SDimitry Andric       std::move(__pred));
162*0fca6ea1SDimitry Andric }
163*0fca6ea1SDimitry Andric 
164*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
165*0fca6ea1SDimitry Andric           class _ForwardIterator1,
166*0fca6ea1SDimitry Andric           class _ForwardIterator2,
167*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
168*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
169*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI bool
170*0fca6ea1SDimitry Andric equal(_ExecutionPolicy&& __policy, _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
171*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "equal requires ForwardIterators");
172*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "equal requires ForwardIterators");
173*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__equal_3leg, __pstl::__current_configuration, _RawPolicy>;
174*0fca6ea1SDimitry Andric   return __pstl::__handle_exception<_Implementation>(
175*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy),
176*0fca6ea1SDimitry Andric       std::move(__first1),
177*0fca6ea1SDimitry Andric       std::move(__last1),
178*0fca6ea1SDimitry Andric       std::move(__first2),
179*0fca6ea1SDimitry Andric       equal_to{});
180*0fca6ea1SDimitry Andric }
181*0fca6ea1SDimitry Andric 
182*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
183*0fca6ea1SDimitry Andric           class _ForwardIterator1,
184*0fca6ea1SDimitry Andric           class _ForwardIterator2,
185*0fca6ea1SDimitry Andric           class _Pred,
186*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
187*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
188*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI bool
189*0fca6ea1SDimitry Andric equal(_ExecutionPolicy&& __policy,
190*0fca6ea1SDimitry Andric       _ForwardIterator1 __first1,
191*0fca6ea1SDimitry Andric       _ForwardIterator1 __last1,
192*0fca6ea1SDimitry Andric       _ForwardIterator2 __first2,
193*0fca6ea1SDimitry Andric       _ForwardIterator2 __last2,
194*0fca6ea1SDimitry Andric       _Pred __pred) {
195*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "equal requires ForwardIterators");
196*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "equal requires ForwardIterators");
197*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__equal, __pstl::__current_configuration, _RawPolicy>;
198*0fca6ea1SDimitry Andric   return __pstl::__handle_exception<_Implementation>(
199*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy),
200*0fca6ea1SDimitry Andric       std::move(__first1),
201*0fca6ea1SDimitry Andric       std::move(__last1),
202*0fca6ea1SDimitry Andric       std::move(__first2),
203*0fca6ea1SDimitry Andric       std::move(__last2),
204*0fca6ea1SDimitry Andric       std::move(__pred));
205*0fca6ea1SDimitry Andric }
206*0fca6ea1SDimitry Andric 
207*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
208*0fca6ea1SDimitry Andric           class _ForwardIterator1,
209*0fca6ea1SDimitry Andric           class _ForwardIterator2,
210*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
211*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
212*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI bool
213*0fca6ea1SDimitry Andric equal(_ExecutionPolicy&& __policy,
214*0fca6ea1SDimitry Andric       _ForwardIterator1 __first1,
215*0fca6ea1SDimitry Andric       _ForwardIterator1 __last1,
216*0fca6ea1SDimitry Andric       _ForwardIterator2 __first2,
217*0fca6ea1SDimitry Andric       _ForwardIterator2 __last2) {
218*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "equal requires ForwardIterators");
219*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "equal requires ForwardIterators");
220*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__equal, __pstl::__current_configuration, _RawPolicy>;
221*0fca6ea1SDimitry Andric   return __pstl::__handle_exception<_Implementation>(
222*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy),
223*0fca6ea1SDimitry Andric       std::move(__first1),
224*0fca6ea1SDimitry Andric       std::move(__last1),
225*0fca6ea1SDimitry Andric       std::move(__first2),
226*0fca6ea1SDimitry Andric       std::move(__last2),
227*0fca6ea1SDimitry Andric       equal_to{});
228*0fca6ea1SDimitry Andric }
229*0fca6ea1SDimitry Andric 
230*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
231*0fca6ea1SDimitry Andric           class _ForwardIterator,
232*0fca6ea1SDimitry Andric           class _Tp,
233*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
234*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
235*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI void
236*0fca6ea1SDimitry Andric fill(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
237*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "fill requires ForwardIterators");
238*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__fill, __pstl::__current_configuration, _RawPolicy>;
239*0fca6ea1SDimitry Andric   __pstl::__handle_exception<_Implementation>(
240*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), __value);
241*0fca6ea1SDimitry Andric }
242*0fca6ea1SDimitry Andric 
243*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
244*0fca6ea1SDimitry Andric           class _ForwardIterator,
245*0fca6ea1SDimitry Andric           class _Size,
246*0fca6ea1SDimitry Andric           class _Tp,
247*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
248*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
249*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI void
250*0fca6ea1SDimitry Andric fill_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n, const _Tp& __value) {
251*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "fill_n requires a ForwardIterator");
252*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__fill_n, __pstl::__current_configuration, _RawPolicy>;
253*0fca6ea1SDimitry Andric   __pstl::__handle_exception<_Implementation>(
254*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__n), __value);
255*0fca6ea1SDimitry Andric }
256*0fca6ea1SDimitry Andric 
257*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
258*0fca6ea1SDimitry Andric           class _ForwardIterator,
259*0fca6ea1SDimitry Andric           class _Predicate,
260*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
261*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
262*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI _ForwardIterator
263*0fca6ea1SDimitry Andric find_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
264*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "find_if requires ForwardIterators");
265*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__find_if, __pstl::__current_configuration, _RawPolicy>;
266*0fca6ea1SDimitry Andric   return __pstl::__handle_exception<_Implementation>(
267*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred));
268*0fca6ea1SDimitry Andric }
269*0fca6ea1SDimitry Andric 
270*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
271*0fca6ea1SDimitry Andric           class _ForwardIterator,
272*0fca6ea1SDimitry Andric           class _Predicate,
273*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
274*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
275*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI _ForwardIterator
276*0fca6ea1SDimitry Andric find_if_not(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
277*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "find_if_not requires ForwardIterators");
278*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__find_if_not, __pstl::__current_configuration, _RawPolicy>;
279*0fca6ea1SDimitry Andric   return __pstl::__handle_exception<_Implementation>(
280*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred));
281*0fca6ea1SDimitry Andric }
282*0fca6ea1SDimitry Andric 
283*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
284*0fca6ea1SDimitry Andric           class _ForwardIterator,
285*0fca6ea1SDimitry Andric           class _Tp,
286*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
287*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
288*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI _ForwardIterator
289*0fca6ea1SDimitry Andric find(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
290*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "find requires ForwardIterators");
291*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__find, __pstl::__current_configuration, _RawPolicy>;
292*0fca6ea1SDimitry Andric   return __pstl::__handle_exception<_Implementation>(
293*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), __value);
294*0fca6ea1SDimitry Andric }
295*0fca6ea1SDimitry Andric 
296*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
297*0fca6ea1SDimitry Andric           class _ForwardIterator,
298*0fca6ea1SDimitry Andric           class _Function,
299*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
300*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
301*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI void
302*0fca6ea1SDimitry Andric for_each(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Function __func) {
303*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "for_each requires ForwardIterators");
304*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__for_each, __pstl::__current_configuration, _RawPolicy>;
305*0fca6ea1SDimitry Andric   __pstl::__handle_exception<_Implementation>(
306*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__func));
307*0fca6ea1SDimitry Andric }
308*0fca6ea1SDimitry Andric 
309*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
310*0fca6ea1SDimitry Andric           class _ForwardIterator,
311*0fca6ea1SDimitry Andric           class _Size,
312*0fca6ea1SDimitry Andric           class _Function,
313*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
314*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
315*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI void
316*0fca6ea1SDimitry Andric for_each_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __size, _Function __func) {
317*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "for_each_n requires a ForwardIterator");
318*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__for_each_n, __pstl::__current_configuration, _RawPolicy>;
319*0fca6ea1SDimitry Andric   __pstl::__handle_exception<_Implementation>(
320*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__size), std::move(__func));
321*0fca6ea1SDimitry Andric }
322*0fca6ea1SDimitry Andric 
323*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
324*0fca6ea1SDimitry Andric           class _ForwardIterator,
325*0fca6ea1SDimitry Andric           class _Generator,
326*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
327*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
328*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI void
329*0fca6ea1SDimitry Andric generate(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Generator __gen) {
330*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "generate requires ForwardIterators");
331*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__generate, __pstl::__current_configuration, _RawPolicy>;
332*0fca6ea1SDimitry Andric   __pstl::__handle_exception<_Implementation>(
333*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__gen));
334*0fca6ea1SDimitry Andric }
335*0fca6ea1SDimitry Andric 
336*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
337*0fca6ea1SDimitry Andric           class _ForwardIterator,
338*0fca6ea1SDimitry Andric           class _Size,
339*0fca6ea1SDimitry Andric           class _Generator,
340*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
341*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
342*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI void
343*0fca6ea1SDimitry Andric generate_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n, _Generator __gen) {
344*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "generate_n requires a ForwardIterator");
345*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__generate_n, __pstl::__current_configuration, _RawPolicy>;
346*0fca6ea1SDimitry Andric   __pstl::__handle_exception<_Implementation>(
347*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__n), std::move(__gen));
348*0fca6ea1SDimitry Andric }
349*0fca6ea1SDimitry Andric 
350*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
351*0fca6ea1SDimitry Andric           class _ForwardIterator,
352*0fca6ea1SDimitry Andric           class _Predicate,
353*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
354*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
355*0fca6ea1SDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool
356*0fca6ea1SDimitry Andric is_partitioned(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
357*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "is_partitioned requires ForwardIterators");
358*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__is_partitioned, __pstl::__current_configuration, _RawPolicy>;
359*0fca6ea1SDimitry Andric   return __pstl::__handle_exception<_Implementation>(
360*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred));
361*0fca6ea1SDimitry Andric }
362*0fca6ea1SDimitry Andric 
363*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
364*0fca6ea1SDimitry Andric           class _ForwardIterator1,
365*0fca6ea1SDimitry Andric           class _ForwardIterator2,
366*0fca6ea1SDimitry Andric           class _ForwardOutIterator,
367*0fca6ea1SDimitry Andric           class _Comp,
368*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
369*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
370*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator
371*0fca6ea1SDimitry Andric merge(_ExecutionPolicy&& __policy,
372*0fca6ea1SDimitry Andric       _ForwardIterator1 __first1,
373*0fca6ea1SDimitry Andric       _ForwardIterator1 __last1,
374*0fca6ea1SDimitry Andric       _ForwardIterator2 __first2,
375*0fca6ea1SDimitry Andric       _ForwardIterator2 __last2,
376*0fca6ea1SDimitry Andric       _ForwardOutIterator __result,
377*0fca6ea1SDimitry Andric       _Comp __comp) {
378*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "merge requires ForwardIterators");
379*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "merge requires ForwardIterators");
380*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, decltype(*__first1), "merge requires an OutputIterator");
381*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, decltype(*__first2), "merge requires an OutputIterator");
382*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__merge, __pstl::__current_configuration, _RawPolicy>;
383*0fca6ea1SDimitry Andric   return __pstl::__handle_exception<_Implementation>(
384*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy),
385*0fca6ea1SDimitry Andric       std::move(__first1),
386*0fca6ea1SDimitry Andric       std::move(__last1),
387*0fca6ea1SDimitry Andric       std::move(__first2),
388*0fca6ea1SDimitry Andric       std::move(__last2),
389*0fca6ea1SDimitry Andric       std::move(__result),
390*0fca6ea1SDimitry Andric       std::move(__comp));
391*0fca6ea1SDimitry Andric }
392*0fca6ea1SDimitry Andric 
393*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
394*0fca6ea1SDimitry Andric           class _ForwardIterator1,
395*0fca6ea1SDimitry Andric           class _ForwardIterator2,
396*0fca6ea1SDimitry Andric           class _ForwardOutIterator,
397*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
398*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
399*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator
400*0fca6ea1SDimitry Andric merge(_ExecutionPolicy&& __policy,
401*0fca6ea1SDimitry Andric       _ForwardIterator1 __first1,
402*0fca6ea1SDimitry Andric       _ForwardIterator1 __last1,
403*0fca6ea1SDimitry Andric       _ForwardIterator2 __first2,
404*0fca6ea1SDimitry Andric       _ForwardIterator2 __last2,
405*0fca6ea1SDimitry Andric       _ForwardOutIterator __result) {
406*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "merge requires ForwardIterators");
407*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "merge requires ForwardIterators");
408*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, decltype(*__first1), "merge requires an OutputIterator");
409*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, decltype(*__first2), "merge requires an OutputIterator");
410*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__merge, __pstl::__current_configuration, _RawPolicy>;
411*0fca6ea1SDimitry Andric   return __pstl::__handle_exception<_Implementation>(
412*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy),
413*0fca6ea1SDimitry Andric       std::move(__first1),
414*0fca6ea1SDimitry Andric       std::move(__last1),
415*0fca6ea1SDimitry Andric       std::move(__first2),
416*0fca6ea1SDimitry Andric       std::move(__last2),
417*0fca6ea1SDimitry Andric       std::move(__result),
418*0fca6ea1SDimitry Andric       less{});
419*0fca6ea1SDimitry Andric }
420*0fca6ea1SDimitry Andric 
421*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
422*0fca6ea1SDimitry Andric           class _ForwardIterator,
423*0fca6ea1SDimitry Andric           class _ForwardOutIterator,
424*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
425*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
426*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator
427*0fca6ea1SDimitry Andric move(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _ForwardOutIterator __result) {
428*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "move requires ForwardIterators");
429*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator, "move requires an OutputIterator");
430*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(
431*0fca6ea1SDimitry Andric       _ForwardOutIterator, decltype(std::move(*__first)), "move requires an OutputIterator");
432*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__move, __pstl::__current_configuration, _RawPolicy>;
433*0fca6ea1SDimitry Andric   return __pstl::__handle_exception<_Implementation>(
434*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__result));
435*0fca6ea1SDimitry Andric }
436*0fca6ea1SDimitry Andric 
437*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
438*0fca6ea1SDimitry Andric           class _ForwardIterator,
439*0fca6ea1SDimitry Andric           class _Pred,
440*0fca6ea1SDimitry Andric           class _Tp,
441*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
442*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
443*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI void
444*0fca6ea1SDimitry Andric replace_if(_ExecutionPolicy&& __policy,
445*0fca6ea1SDimitry Andric            _ForwardIterator __first,
446*0fca6ea1SDimitry Andric            _ForwardIterator __last,
447*0fca6ea1SDimitry Andric            _Pred __pred,
448*0fca6ea1SDimitry Andric            const _Tp& __new_value) {
449*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "replace_if requires ForwardIterators");
450*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__replace_if, __pstl::__current_configuration, _RawPolicy>;
451*0fca6ea1SDimitry Andric   __pstl::__handle_exception<_Implementation>(
452*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred), __new_value);
453*0fca6ea1SDimitry Andric }
454*0fca6ea1SDimitry Andric 
455*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
456*0fca6ea1SDimitry Andric           class _ForwardIterator,
457*0fca6ea1SDimitry Andric           class _Tp,
458*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
459*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
460*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI void
461*0fca6ea1SDimitry Andric replace(_ExecutionPolicy&& __policy,
462*0fca6ea1SDimitry Andric         _ForwardIterator __first,
463*0fca6ea1SDimitry Andric         _ForwardIterator __last,
464*0fca6ea1SDimitry Andric         const _Tp& __old_value,
465*0fca6ea1SDimitry Andric         const _Tp& __new_value) {
466*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "replace requires ForwardIterators");
467*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__replace, __pstl::__current_configuration, _RawPolicy>;
468*0fca6ea1SDimitry Andric   __pstl::__handle_exception<_Implementation>(
469*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), __old_value, __new_value);
470*0fca6ea1SDimitry Andric }
471*0fca6ea1SDimitry Andric 
472*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
473*0fca6ea1SDimitry Andric           class _ForwardIterator,
474*0fca6ea1SDimitry Andric           class _ForwardOutIterator,
475*0fca6ea1SDimitry Andric           class _Pred,
476*0fca6ea1SDimitry Andric           class _Tp,
477*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
478*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
479*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI void replace_copy_if(
480*0fca6ea1SDimitry Andric     _ExecutionPolicy&& __policy,
481*0fca6ea1SDimitry Andric     _ForwardIterator __first,
482*0fca6ea1SDimitry Andric     _ForwardIterator __last,
483*0fca6ea1SDimitry Andric     _ForwardOutIterator __result,
484*0fca6ea1SDimitry Andric     _Pred __pred,
485*0fca6ea1SDimitry Andric     const _Tp& __new_value) {
486*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "replace_copy_if requires ForwardIterators");
487*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator, "replace_copy_if requires ForwardIterators");
488*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(
489*0fca6ea1SDimitry Andric       _ForwardOutIterator, decltype(*__first), "replace_copy_if requires an OutputIterator");
490*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, const _Tp&, "replace_copy requires an OutputIterator");
491*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__replace_copy_if, __pstl::__current_configuration, _RawPolicy>;
492*0fca6ea1SDimitry Andric   __pstl::__handle_exception<_Implementation>(
493*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy),
494*0fca6ea1SDimitry Andric       std::move(__first),
495*0fca6ea1SDimitry Andric       std::move(__last),
496*0fca6ea1SDimitry Andric       std::move(__result),
497*0fca6ea1SDimitry Andric       std::move(__pred),
498*0fca6ea1SDimitry Andric       __new_value);
499*0fca6ea1SDimitry Andric }
500*0fca6ea1SDimitry Andric 
501*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
502*0fca6ea1SDimitry Andric           class _ForwardIterator,
503*0fca6ea1SDimitry Andric           class _ForwardOutIterator,
504*0fca6ea1SDimitry Andric           class _Tp,
505*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
506*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
507*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI void replace_copy(
508*0fca6ea1SDimitry Andric     _ExecutionPolicy&& __policy,
509*0fca6ea1SDimitry Andric     _ForwardIterator __first,
510*0fca6ea1SDimitry Andric     _ForwardIterator __last,
511*0fca6ea1SDimitry Andric     _ForwardOutIterator __result,
512*0fca6ea1SDimitry Andric     const _Tp& __old_value,
513*0fca6ea1SDimitry Andric     const _Tp& __new_value) {
514*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "replace_copy requires ForwardIterators");
515*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator, "replace_copy requires ForwardIterators");
516*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(
517*0fca6ea1SDimitry Andric       _ForwardOutIterator, decltype(*__first), "replace_copy requires an OutputIterator");
518*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, const _Tp&, "replace_copy requires an OutputIterator");
519*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__replace_copy, __pstl::__current_configuration, _RawPolicy>;
520*0fca6ea1SDimitry Andric   __pstl::__handle_exception<_Implementation>(
521*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy),
522*0fca6ea1SDimitry Andric       std::move(__first),
523*0fca6ea1SDimitry Andric       std::move(__last),
524*0fca6ea1SDimitry Andric       std::move(__result),
525*0fca6ea1SDimitry Andric       __old_value,
526*0fca6ea1SDimitry Andric       __new_value);
527*0fca6ea1SDimitry Andric }
528*0fca6ea1SDimitry Andric 
529*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
530*0fca6ea1SDimitry Andric           class _ForwardIterator,
531*0fca6ea1SDimitry Andric           class _ForwardOutIterator,
532*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
533*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
534*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator rotate_copy(
535*0fca6ea1SDimitry Andric     _ExecutionPolicy&& __policy,
536*0fca6ea1SDimitry Andric     _ForwardIterator __first,
537*0fca6ea1SDimitry Andric     _ForwardIterator __middle,
538*0fca6ea1SDimitry Andric     _ForwardIterator __last,
539*0fca6ea1SDimitry Andric     _ForwardOutIterator __result) {
540*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "rotate_copy requires ForwardIterators");
541*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator, "rotate_copy requires ForwardIterators");
542*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(
543*0fca6ea1SDimitry Andric       _ForwardOutIterator, decltype(*__first), "rotate_copy requires an OutputIterator");
544*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__rotate_copy, __pstl::__current_configuration, _RawPolicy>;
545*0fca6ea1SDimitry Andric   return __pstl::__handle_exception<_Implementation>(
546*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy),
547*0fca6ea1SDimitry Andric       std::move(__first),
548*0fca6ea1SDimitry Andric       std::move(__middle),
549*0fca6ea1SDimitry Andric       std::move(__last),
550*0fca6ea1SDimitry Andric       std::move(__result));
551*0fca6ea1SDimitry Andric }
552*0fca6ea1SDimitry Andric 
553*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
554*0fca6ea1SDimitry Andric           class _RandomAccessIterator,
555*0fca6ea1SDimitry Andric           class _Comp,
556*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
557*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
558*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI void
559*0fca6ea1SDimitry Andric sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) {
560*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(_RandomAccessIterator, "sort requires RandomAccessIterators");
561*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__sort, __pstl::__current_configuration, _RawPolicy>;
562*0fca6ea1SDimitry Andric   __pstl::__handle_exception<_Implementation>(
563*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__comp));
564*0fca6ea1SDimitry Andric }
565*0fca6ea1SDimitry Andric 
566*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
567*0fca6ea1SDimitry Andric           class _RandomAccessIterator,
568*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
569*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
570*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI void
571*0fca6ea1SDimitry Andric sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last) {
572*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(_RandomAccessIterator, "sort requires RandomAccessIterators");
573*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__sort, __pstl::__current_configuration, _RawPolicy>;
574*0fca6ea1SDimitry Andric   __pstl::__handle_exception<_Implementation>(
575*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), less{});
576*0fca6ea1SDimitry Andric }
577*0fca6ea1SDimitry Andric 
578*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
579*0fca6ea1SDimitry Andric           class _RandomAccessIterator,
580*0fca6ea1SDimitry Andric           class _Comp,
581*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
582*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
583*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI void
584*0fca6ea1SDimitry Andric stable_sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) {
585*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(_RandomAccessIterator, "stable_sort requires RandomAccessIterators");
586*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__stable_sort, __pstl::__current_configuration, _RawPolicy>;
587*0fca6ea1SDimitry Andric   __pstl::__handle_exception<_Implementation>(
588*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__comp));
589*0fca6ea1SDimitry Andric }
590*0fca6ea1SDimitry Andric 
591*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
592*0fca6ea1SDimitry Andric           class _RandomAccessIterator,
593*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
594*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
595*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI void
596*0fca6ea1SDimitry Andric stable_sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last) {
597*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(_RandomAccessIterator, "stable_sort requires RandomAccessIterators");
598*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__stable_sort, __pstl::__current_configuration, _RawPolicy>;
599*0fca6ea1SDimitry Andric   __pstl::__handle_exception<_Implementation>(
600*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), less{});
601*0fca6ea1SDimitry Andric }
602*0fca6ea1SDimitry Andric 
603*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
604*0fca6ea1SDimitry Andric           class _ForwardIterator,
605*0fca6ea1SDimitry Andric           class _ForwardOutIterator,
606*0fca6ea1SDimitry Andric           class _UnaryOperation,
607*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
608*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
609*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform(
610*0fca6ea1SDimitry Andric     _ExecutionPolicy&& __policy,
611*0fca6ea1SDimitry Andric     _ForwardIterator __first,
612*0fca6ea1SDimitry Andric     _ForwardIterator __last,
613*0fca6ea1SDimitry Andric     _ForwardOutIterator __result,
614*0fca6ea1SDimitry Andric     _UnaryOperation __op) {
615*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "transform requires ForwardIterators");
616*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator, "transform requires an OutputIterator");
617*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(
618*0fca6ea1SDimitry Andric       _ForwardOutIterator, decltype(__op(*__first)), "transform requires an OutputIterator");
619*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__transform, __pstl::__current_configuration, _RawPolicy>;
620*0fca6ea1SDimitry Andric   return __pstl::__handle_exception<_Implementation>(
621*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy),
622*0fca6ea1SDimitry Andric       std::move(__first),
623*0fca6ea1SDimitry Andric       std::move(__last),
624*0fca6ea1SDimitry Andric       std::move(__result),
625*0fca6ea1SDimitry Andric       std::move(__op));
626*0fca6ea1SDimitry Andric }
627*0fca6ea1SDimitry Andric 
628*0fca6ea1SDimitry Andric template <class _ExecutionPolicy,
629*0fca6ea1SDimitry Andric           class _ForwardIterator1,
630*0fca6ea1SDimitry Andric           class _ForwardIterator2,
631*0fca6ea1SDimitry Andric           class _ForwardOutIterator,
632*0fca6ea1SDimitry Andric           class _BinaryOperation,
633*0fca6ea1SDimitry Andric           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
634*0fca6ea1SDimitry Andric           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
635*0fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform(
636*0fca6ea1SDimitry Andric     _ExecutionPolicy&& __policy,
637*0fca6ea1SDimitry Andric     _ForwardIterator1 __first1,
638*0fca6ea1SDimitry Andric     _ForwardIterator1 __last1,
639*0fca6ea1SDimitry Andric     _ForwardIterator2 __first2,
640*0fca6ea1SDimitry Andric     _ForwardOutIterator __result,
641*0fca6ea1SDimitry Andric     _BinaryOperation __op) {
642*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "transform requires ForwardIterators");
643*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "transform requires ForwardIterators");
644*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator, "transform requires an OutputIterator");
645*0fca6ea1SDimitry Andric   _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(
646*0fca6ea1SDimitry Andric       _ForwardOutIterator, decltype(__op(*__first1, *__first2)), "transform requires an OutputIterator");
647*0fca6ea1SDimitry Andric   using _Implementation = __pstl::__dispatch<__pstl::__transform_binary, __pstl::__current_configuration, _RawPolicy>;
648*0fca6ea1SDimitry Andric   return __pstl::__handle_exception<_Implementation>(
649*0fca6ea1SDimitry Andric       std::forward<_ExecutionPolicy>(__policy),
650*0fca6ea1SDimitry Andric       std::move(__first1),
651*0fca6ea1SDimitry Andric       std::move(__last1),
652*0fca6ea1SDimitry Andric       std::move(__first2),
653*0fca6ea1SDimitry Andric       std::move(__result),
654*0fca6ea1SDimitry Andric       std::move(__op));
655*0fca6ea1SDimitry Andric }
656*0fca6ea1SDimitry Andric 
657*0fca6ea1SDimitry Andric _LIBCPP_END_NAMESPACE_STD
658*0fca6ea1SDimitry Andric 
659*0fca6ea1SDimitry Andric #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
660*0fca6ea1SDimitry Andric 
661*0fca6ea1SDimitry Andric _LIBCPP_POP_MACROS
662*0fca6ea1SDimitry Andric 
663*0fca6ea1SDimitry Andric #endif // _LIBCPP___ALGORITHM_PSTL_H
664