Warning: This file is not a C or C++ file. It does not have highlighting.
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_DIFFERENCE_H |
10 | #define _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H |
11 | |
12 | #include <__algorithm/in_out_result.h> |
13 | #include <__algorithm/make_projected.h> |
14 | #include <__algorithm/set_difference.h> |
15 | #include <__config> |
16 | #include <__functional/identity.h> |
17 | #include <__functional/invoke.h> |
18 | #include <__functional/ranges_operations.h> |
19 | #include <__iterator/concepts.h> |
20 | #include <__iterator/mergeable.h> |
21 | #include <__ranges/access.h> |
22 | #include <__ranges/concepts.h> |
23 | #include <__ranges/dangling.h> |
24 | #include <__type_traits/decay.h> |
25 | #include <__utility/move.h> |
26 | #include <__utility/pair.h> |
27 | |
28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
29 | # pragma GCC system_header |
30 | #endif |
31 | |
32 | _LIBCPP_PUSH_MACROS |
33 | #include <__undef_macros> |
34 | |
35 | #if _LIBCPP_STD_VER >= 20 |
36 | |
37 | _LIBCPP_BEGIN_NAMESPACE_STD |
38 | |
39 | namespace ranges { |
40 | |
41 | template <class _InIter, class _OutIter> |
42 | using set_difference_result = in_out_result<_InIter, _OutIter>; |
43 | |
44 | struct __set_difference { |
45 | template <input_iterator _InIter1, |
46 | sentinel_for<_InIter1> _Sent1, |
47 | input_iterator _InIter2, |
48 | sentinel_for<_InIter2> _Sent2, |
49 | weakly_incrementable _OutIter, |
50 | class _Comp = less, |
51 | class _Proj1 = identity, |
52 | class _Proj2 = identity> |
53 | requires mergeable<_InIter1, _InIter2, _OutIter, _Comp, _Proj1, _Proj2> |
54 | _LIBCPP_HIDE_FROM_ABI constexpr set_difference_result<_InIter1, _OutIter> operator()( |
55 | _InIter1 __first1, |
56 | _Sent1 __last1, |
57 | _InIter2 __first2, |
58 | _Sent2 __last2, |
59 | _OutIter __result, |
60 | _Comp __comp = {}, |
61 | _Proj1 __proj1 = {}, |
62 | _Proj2 __proj2 = {}) const { |
63 | auto __ret = std::__set_difference( |
64 | __first1, __last1, __first2, __last2, __result, ranges::__make_projected_comp(__comp, __proj1, __proj2)); |
65 | return {std::move(__ret.first), std::move(__ret.second)}; |
66 | } |
67 | |
68 | template <input_range _Range1, |
69 | input_range _Range2, |
70 | weakly_incrementable _OutIter, |
71 | class _Comp = less, |
72 | class _Proj1 = identity, |
73 | class _Proj2 = identity> |
74 | requires mergeable<iterator_t<_Range1>, iterator_t<_Range2>, _OutIter, _Comp, _Proj1, _Proj2> |
75 | _LIBCPP_HIDE_FROM_ABI constexpr set_difference_result<borrowed_iterator_t<_Range1>, _OutIter> |
76 | operator()(_Range1&& __range1, |
77 | _Range2&& __range2, |
78 | _OutIter __result, |
79 | _Comp __comp = {}, |
80 | _Proj1 __proj1 = {}, |
81 | _Proj2 __proj2 = {}) const { |
82 | auto __ret = std::__set_difference( |
83 | ranges::begin(__range1), |
84 | ranges::end(__range1), |
85 | ranges::begin(__range2), |
86 | ranges::end(__range2), |
87 | __result, |
88 | ranges::__make_projected_comp(__comp, __proj1, __proj2)); |
89 | return {std::move(__ret.first), std::move(__ret.second)}; |
90 | } |
91 | }; |
92 | |
93 | inline namespace __cpo { |
94 | inline constexpr auto set_difference = __set_difference{}; |
95 | } // namespace __cpo |
96 | } // namespace ranges |
97 | |
98 | _LIBCPP_END_NAMESPACE_STD |
99 | |
100 | #endif // _LIBCPP_STD_VER >= 20 |
101 | |
102 | _LIBCPP_POP_MACROS |
103 | |
104 | #endif // _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H |
105 |
Warning: This file is not a C or C++ file. It does not have highlighting.