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