pstl_merge.h 1.9 KB

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