| 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___MEMORY_PSTL_H |
| 10 | #define _LIBCPP___MEMORY_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 _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17 |
| 22 | |
| 23 | # include <__iterator/cpp17_iterator_concepts.h> |
| 24 | # include <__iterator/iterator_traits.h> |
| 25 | # include <__pstl/backend.h> |
| 26 | # include <__pstl/dispatch.h> |
| 27 | # include <__pstl/handle_exception.h> |
| 28 | # include <__type_traits/enable_if.h> |
| 29 | # include <__type_traits/is_execution_policy.h> |
| 30 | # include <__type_traits/remove_cvref.h> |
| 31 | # include <__utility/forward.h> |
| 32 | # include <__utility/move.h> |
| 33 | |
| 34 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 35 | |
| 36 | template <class _ExecutionPolicy, |
| 37 | class _ForwardIterator, |
| 38 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, |
| 39 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> |
| 40 | _LIBCPP_HIDE_FROM_ABI void destroy(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last) { |
| 41 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "destroy requires ForwardIterators" ); |
| 42 | using _Implementation = __pstl::__dispatch<__pstl::__destroy, __pstl::__current_configuration, _RawPolicy>; |
| 43 | __pstl::__handle_exception<_Implementation>( |
| 44 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last)); |
| 45 | } |
| 46 | |
| 47 | template <class _ExecutionPolicy, |
| 48 | class _ForwardIterator, |
| 49 | class _Size, |
| 50 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, |
| 51 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> |
| 52 | _LIBCPP_HIDE_FROM_ABI void destroy_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n) { |
| 53 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "destroy_n requires ForwardIterators" ); |
| 54 | using _Implementation = __pstl::__dispatch<__pstl::__destroy_n, __pstl::__current_configuration, _RawPolicy>; |
| 55 | __pstl::__handle_exception<_Implementation>(std::forward<_ExecutionPolicy>(__policy), std::move(__first), __n); |
| 56 | } |
| 57 | |
| 58 | template <class _ExecutionPolicy, |
| 59 | class _ForwardIterator, |
| 60 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, |
| 61 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> |
| 62 | _LIBCPP_HIDE_FROM_ABI void |
| 63 | uninitialized_default_construct(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last) { |
| 64 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "uninitialized_default_construct requires ForwardIterators" ); |
| 65 | using _Implementation = |
| 66 | __pstl::__dispatch<__pstl::__uninitialized_default_construct, __pstl::__current_configuration, _RawPolicy>; |
| 67 | __pstl::__handle_exception<_Implementation>( |
| 68 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last)); |
| 69 | } |
| 70 | |
| 71 | template <class _ExecutionPolicy, |
| 72 | class _ForwardIterator, |
| 73 | class _Size, |
| 74 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, |
| 75 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> |
| 76 | _LIBCPP_HIDE_FROM_ABI void |
| 77 | uninitialized_default_construct_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n) { |
| 78 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR( |
| 79 | _ForwardIterator, "uninitialized_default_construct_n requires ForwardIterators" ); |
| 80 | using _Implementation = |
| 81 | __pstl::__dispatch<__pstl::__uninitialized_default_construct_n, __pstl::__current_configuration, _RawPolicy>; |
| 82 | __pstl::__handle_exception<_Implementation>(std::forward<_ExecutionPolicy>(__policy), std::move(__first), __n); |
| 83 | } |
| 84 | |
| 85 | template <class _ExecutionPolicy, |
| 86 | class _ForwardIterator, |
| 87 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, |
| 88 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> |
| 89 | _LIBCPP_HIDE_FROM_ABI void |
| 90 | uninitialized_value_construct(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last) { |
| 91 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "uninitialized_value_construct requires ForwardIterators" ); |
| 92 | using _Implementation = |
| 93 | __pstl::__dispatch<__pstl::__uninitialized_value_construct, __pstl::__current_configuration, _RawPolicy>; |
| 94 | __pstl::__handle_exception<_Implementation>( |
| 95 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last)); |
| 96 | } |
| 97 | |
| 98 | template <class _ExecutionPolicy, |
| 99 | class _ForwardIterator, |
| 100 | class _Size, |
| 101 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, |
| 102 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> |
| 103 | _LIBCPP_HIDE_FROM_ABI void |
| 104 | uninitialized_value_construct_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n) { |
| 105 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "uninitialized_value_construct_n requires ForwardIterators" ); |
| 106 | using _Implementation = |
| 107 | __pstl::__dispatch<__pstl::__uninitialized_value_construct_n, __pstl::__current_configuration, _RawPolicy>; |
| 108 | __pstl::__handle_exception<_Implementation>(std::forward<_ExecutionPolicy>(__policy), std::move(__first), __n); |
| 109 | } |
| 110 | |
| 111 | template <class _ExecutionPolicy, |
| 112 | class _ForwardIterator, |
| 113 | class _Tp, |
| 114 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, |
| 115 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> |
| 116 | _LIBCPP_HIDE_FROM_ABI void |
| 117 | uninitialized_fill(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { |
| 118 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "uninitialized_fill requires ForwardIterators" ); |
| 119 | using _Implementation = __pstl::__dispatch<__pstl::__uninitialized_fill, __pstl::__current_configuration, _RawPolicy>; |
| 120 | __pstl::__handle_exception<_Implementation>( |
| 121 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), __value); |
| 122 | } |
| 123 | |
| 124 | template <class _ExecutionPolicy, |
| 125 | class _ForwardIterator, |
| 126 | class _Size, |
| 127 | class _Tp, |
| 128 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, |
| 129 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> |
| 130 | _LIBCPP_HIDE_FROM_ABI void |
| 131 | uninitialized_fill_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n, const _Tp& __value) { |
| 132 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "uninitialized_fill_n requires ForwardIterators" ); |
| 133 | using _Implementation = |
| 134 | __pstl::__dispatch<__pstl::__uninitialized_fill_n, __pstl::__current_configuration, _RawPolicy>; |
| 135 | __pstl::__handle_exception<_Implementation>( |
| 136 | std::forward<_ExecutionPolicy>(__policy), std::move(__first), __n, __value); |
| 137 | } |
| 138 | |
| 139 | _LIBCPP_END_NAMESPACE_STD |
| 140 | |
| 141 | #endif // _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17 |
| 142 | |
| 143 | _LIBCPP_POP_MACROS |
| 144 | |
| 145 | #endif // _LIBCPP___MEMORY_PSTL_H |
| 146 | |