diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2023-12-18 20:30:12 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2024-04-19 21:12:03 +0000 |
| commit | c9157d925c489f07ba9c0b2ce47e5149b75969a5 (patch) | |
| tree | 08bc4a3d9cad3f9ebffa558ddf140b9d9257b219 /contrib/llvm-project/libcxx/include/__algorithm/pstl_merge.h | |
| parent | 2a66844f606a35d68ad8a8061f4bea204274b3bc (diff) | |
Diffstat (limited to 'contrib/llvm-project/libcxx/include/__algorithm/pstl_merge.h')
| -rw-r--r-- | contrib/llvm-project/libcxx/include/__algorithm/pstl_merge.h | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_merge.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_merge.h index f10ac7674282..ed8014510863 100644 --- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_merge.h +++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_merge.h @@ -16,6 +16,7 @@ #include <__type_traits/is_execution_policy.h> #include <__type_traits/remove_cvref.h> #include <__utility/move.h> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -32,23 +33,51 @@ template <class _ExecutionPolicy, class _Comp = std::less<>, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> +__merge(_ExecutionPolicy&&, + _ForwardIterator1 __first1, + _ForwardIterator1 __last1, + _ForwardIterator2 __first2, + _ForwardIterator2 __last2, + _ForwardOutIterator __result, + _Comp __comp = {}) noexcept { + using _Backend = typename __select_backend<_RawPolicy>::type; + return std::__pstl_merge<_RawPolicy>( + _Backend{}, + std::move(__first1), + std::move(__last1), + std::move(__first2), + std::move(__last2), + std::move(__result), + std::move(__comp)); +} + +template <class _ExecutionPolicy, + class _ForwardIterator1, + class _ForwardIterator2, + class _ForwardOutIterator, + class _Comp = std::less<>, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator -merge(_ExecutionPolicy&&, +merge(_ExecutionPolicy&& __policy, _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _ForwardOutIterator __result, _Comp __comp = {}) { - using _Backend = typename __select_backend<_RawPolicy>::type; - return std::__pstl_merge<_RawPolicy>( - _Backend{}, + auto __res = std::__merge( + __policy, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), std::move(__result), std::move(__comp)); + if (!__res) + std::__throw_bad_alloc(); + return *std::move(__res); } _LIBCPP_END_NAMESPACE_STD |
