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___ALGORITHM_PSTL_MERGE_H
10 #define _LIBCPP___ALGORITHM_PSTL_MERGE_H
11 
12 #include <__algorithm/pstl_backend.h>
13 #include <__config>
14 #include <__functional/operations.h>
15 #include <__type_traits/enable_if.h>
16 #include <__type_traits/is_execution_policy.h>
17 #include <__type_traits/remove_cvref.h>
18 #include <__utility/move.h>
19 
20 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21 #  pragma GCC system_header
22 #endif
23 
24 #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
25 
26 _LIBCPP_BEGIN_NAMESPACE_STD
27 
28 template <class _ExecutionPolicy,
29           class _ForwardIterator1,
30           class _ForwardIterator2,
31           class _ForwardOutIterator,
32           class _Comp                                         = std::less<>,
33           class _RawPolicy                                    = __remove_cvref_t<_ExecutionPolicy>,
34           enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
35 _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator
36 merge(_ExecutionPolicy&&,
37       _ForwardIterator1 __first1,
38       _ForwardIterator1 __last1,
39       _ForwardIterator2 __first2,
40       _ForwardIterator2 __last2,
41       _ForwardOutIterator __result,
42       _Comp __comp = {}) {
43   using _Backend = typename __select_backend<_RawPolicy>::type;
44   return std::__pstl_merge<_RawPolicy>(
45       _Backend{},
46       std::move(__first1),
47       std::move(__last1),
48       std::move(__first2),
49       std::move(__last2),
50       std::move(__result),
51       std::move(__comp));
52 }
53 
54 _LIBCPP_END_NAMESPACE_STD
55 
56 #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
57 
58 #endif // _LIBCPP___ALGORITHM_PSTL_MERGE_H
59