| 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_RANGES_SET_UNION_H |
| 10 |
#define _LIBCPP___ALGORITHM_RANGES_SET_UNION_H |
| 11 |
|
| 12 |
#include <__algorithm/in_in_out_result.h> |
| 13 |
#include <__algorithm/iterator_operations.h> |
| 14 |
#include <__algorithm/make_projected.h> |
| 15 |
#include <__algorithm/set_union.h> |
| 16 |
#include <__config> |
| 17 |
#include <__functional/identity.h> |
| 18 |
#include <__functional/invoke.h> |
| 19 |
#include <__functional/ranges_operations.h> |
| 20 |
#include <__iterator/concepts.h> |
| 21 |
#include <__iterator/iterator_traits.h> |
| 22 |
#include <__iterator/mergeable.h> |
| 23 |
#include <__iterator/projected.h> |
| 24 |
#include <__ranges/access.h> |
| 25 |
#include <__ranges/concepts.h> |
| 26 |
#include <__ranges/dangling.h> |
| 27 |
#include <__utility/forward.h> |
| 28 |
#include <__utility/move.h> |
| 29 |
|
| 30 |
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 31 |
# pragma GCC system_header |
| 32 |
#endif |
| 33 |
|
| 34 |
_LIBCPP_PUSH_MACROS |
| 35 |
#include <__undef_macros> |
| 36 |
|
| 37 |
#if _LIBCPP_STD_VER >= 20 |
| 38 |
|
| 39 |
_LIBCPP_BEGIN_NAMESPACE_STD |
| 40 |
|
| 41 |
namespace ranges { |
| 42 |
|
| 43 |
template <class _InIter1, class _InIter2, class _OutIter> |
| 44 |
using set_union_result = in_in_out_result<_InIter1, _InIter2, _OutIter>; |
| 45 |
|
| 46 |
namespace __set_union { |
| 47 |
|
| 48 |
struct __fn { |
| 49 |
template <input_iterator _InIter1, |
| 50 |
sentinel_for<_InIter1> _Sent1, |
| 51 |
input_iterator _InIter2, |
| 52 |
sentinel_for<_InIter2> _Sent2, |
| 53 |
weakly_incrementable _OutIter, |
| 54 |
class _Comp = ranges::less, |
| 55 |
class _Proj1 = identity, |
| 56 |
class _Proj2 = identity> |
| 57 |
requires mergeable<_InIter1, _InIter2, _OutIter, _Comp, _Proj1, _Proj2> |
| 58 |
_LIBCPP_HIDE_FROM_ABI constexpr set_union_result<_InIter1, _InIter2, _OutIter> operator()( |
| 59 |
_InIter1 __first1, |
| 60 |
_Sent1 __last1, |
| 61 |
_InIter2 __first2, |
| 62 |
_Sent2 __last2, |
| 63 |
_OutIter __result, |
| 64 |
_Comp __comp = {}, |
| 65 |
_Proj1 __proj1 = {}, |
| 66 |
_Proj2 __proj2 = {}) const { |
| 67 |
auto __ret = std::__set_union<_RangeAlgPolicy>( |
| 68 |
std::move(__first1), |
| 69 |
std::move(__last1), |
| 70 |
std::move(__first2), |
| 71 |
std::move(__last2), |
| 72 |
std::move(__result), |
| 73 |
ranges::__make_projected_comp(__comp, __proj1, __proj2)); |
| 74 |
return {std::move(__ret.__in1_), std::move(__ret.__in2_), std::move(__ret.__out_)}; |
| 75 |
} |
| 76 |
|
| 77 |
template <input_range _Range1, |
| 78 |
input_range _Range2, |
| 79 |
weakly_incrementable _OutIter, |
| 80 |
class _Comp = ranges::less, |
| 81 |
class _Proj1 = identity, |
| 82 |
class _Proj2 = identity> |
| 83 |
requires mergeable<iterator_t<_Range1>, iterator_t<_Range2>, _OutIter, _Comp, _Proj1, _Proj2> |
| 84 |
_LIBCPP_HIDE_FROM_ABI constexpr set_union_result<borrowed_iterator_t<_Range1>, borrowed_iterator_t<_Range2>, _OutIter> |
| 85 |
operator()(_Range1&& __range1, |
| 86 |
_Range2&& __range2, |
| 87 |
_OutIter __result, |
| 88 |
_Comp __comp = {}, |
| 89 |
_Proj1 __proj1 = {}, |
| 90 |
_Proj2 __proj2 = {}) const { |
| 91 |
auto __ret = std::__set_union<_RangeAlgPolicy>( |
| 92 |
ranges::begin(__range1), |
| 93 |
ranges::end(__range1), |
| 94 |
ranges::begin(__range2), |
| 95 |
ranges::end(__range2), |
| 96 |
std::move(__result), |
| 97 |
ranges::__make_projected_comp(__comp, __proj1, __proj2)); |
| 98 |
return {std::move(__ret.__in1_), std::move(__ret.__in2_), std::move(__ret.__out_)}; |
| 99 |
} |
| 100 |
}; |
| 101 |
|
| 102 |
} // namespace __set_union |
| 103 |
|
| 104 |
inline namespace __cpo { |
| 105 |
inline constexpr auto set_union = __set_union::__fn{}; |
| 106 |
} // namespace __cpo |
| 107 |
} // namespace ranges |
| 108 |
|
| 109 |
_LIBCPP_END_NAMESPACE_STD |
| 110 |
|
| 111 |
#endif // _LIBCPP_STD_VER >= 20 |
| 112 |
|
| 113 |
_LIBCPP_POP_MACROS |
| 114 |
|
| 115 |
#endif // _LIBCPP___ALGORITHM_RANGES_SET_UNION_H |