summaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_merge.h
diff options
context:
space:
mode:
authormikhnenko <[email protected]>2024-11-15 10:28:14 +0300
committermikhnenko <[email protected]>2024-11-15 10:39:55 +0300
commit63e58b6e405f754c634aac8411c84da160b4c574 (patch)
treee93aa558728b77f263074a89ea1e7ba7849f6b7a /contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_merge.h
parent423f17a2717306abbb05e18c17c1dcfe0bd89558 (diff)
Update libcxx to 19 Oct d173ce4a670e88b65c52f6fc1bf10d133ee35704
commit_hash:c1da7a8a6580c15e8af41b1a4847da2163706905
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_merge.h')
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_merge.h37
1 files changed, 33 insertions, 4 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_merge.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_merge.h
index f10ac767428..ed801451086 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_merge.h
+++ b/contrib/libs/cxxsupp/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