1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef _LIBCPP___ALGORITHM_PSTL_ROTATE_COPY_H
10 #define _LIBCPP___ALGORITHM_PSTL_ROTATE_COPY_H
12 #include <__algorithm/pstl_backend.h>
13 #include <__algorithm/pstl_copy.h>
14 #include <__algorithm/pstl_frontend_dispatch.h>
15 #include <__type_traits/is_execution_policy.h>
17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18 # pragma GCC system_header
21 #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
23 _LIBCPP_BEGIN_NAMESPACE_STD
26 void __pstl_rotate_copy();
28 template <class _ExecutionPolicy
,
29 class _ForwardIterator
,
30 class _ForwardOutIterator
,
31 class _RawPolicy
= __remove_cvref_t
<_ExecutionPolicy
>,
32 enable_if_t
<is_execution_policy_v
<_RawPolicy
>, int> = 0>
33 [[nodiscard
]] _LIBCPP_HIDE_FROM_ABI optional
<_ForwardOutIterator
>
34 __rotate_copy(_ExecutionPolicy
&& __policy
,
35 _ForwardIterator
&& __first
,
36 _ForwardIterator
&& __middle
,
37 _ForwardIterator
&& __last
,
38 _ForwardOutIterator
&& __result
) noexcept
{
39 return std::__pstl_frontend_dispatch(
40 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_rotate_copy
, _RawPolicy
),
41 [&__policy
](_ForwardIterator __g_first
,
42 _ForwardIterator __g_middle
,
43 _ForwardIterator __g_last
,
44 _ForwardOutIterator __g_result
) -> optional
<_ForwardOutIterator
> {
46 std::__copy(__policy
, _ForwardIterator(__g_middle
), std::move(__g_last
), std::move(__g_result
));
49 return std::__copy(__policy
, std::move(__g_first
), std::move(__g_middle
), *std::move(__result_mid
));
57 template <class _ExecutionPolicy
,
58 class _ForwardIterator
,
59 class _ForwardOutIterator
,
60 class _RawPolicy
= __remove_cvref_t
<_ExecutionPolicy
>,
61 enable_if_t
<is_execution_policy_v
<_RawPolicy
>, int> = 0>
62 _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator
rotate_copy(
63 _ExecutionPolicy
&& __policy
,
64 _ForwardIterator __first
,
65 _ForwardIterator __middle
,
66 _ForwardIterator __last
,
67 _ForwardOutIterator __result
) {
69 std::__rotate_copy(__policy
, std::move(__first
), std::move(__middle
), std::move(__last
), std::move(__result
));
71 std::__throw_bad_alloc();
75 _LIBCPP_END_NAMESPACE_STD
77 #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
79 #endif // _LIBCPP___ALGORITHM_PSTL_ROTATE_COPY_H