aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_merge.h
diff options
context:
space:
mode:
authorMaxim Yurchuk <maxim-yurchuk@ydb.tech>2024-11-20 17:37:57 +0000
committerGitHub <noreply@github.com>2024-11-20 17:37:57 +0000
commitf76323e9b295c15751e51e3443aa47a36bee8023 (patch)
tree4113c8cad473a33e0f746966e0cf087252fa1d7a /contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_merge.h
parent753ecb8d410a4cb459c26f3a0082fb2d1724fe63 (diff)
parenta7b9a6afea2a9d7a7bfac4c5eb4c1a8e60adb9e6 (diff)
downloadydb-f76323e9b295c15751e51e3443aa47a36bee8023.tar.gz
Merge pull request #11788 from ydb-platform/mergelibs-241120-1113
Library import 241120-1113
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 f10ac76742..ed80145108 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