1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H
10 #define _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H
12 #include <__cxx03/__algorithm/in_out_result.h>
13 #include <__cxx03/__algorithm/iterator_operations.h>
14 #include <__cxx03/__algorithm/make_projected.h>
15 #include <__cxx03/__algorithm/set_difference.h>
16 #include <__cxx03/__config>
17 #include <__cxx03/__functional/identity.h>
18 #include <__cxx03/__functional/invoke.h>
19 #include <__cxx03/__functional/ranges_operations.h>
20 #include <__cxx03/__iterator/concepts.h>
21 #include <__cxx03/__iterator/mergeable.h>
22 #include <__cxx03/__ranges/access.h>
23 #include <__cxx03/__ranges/concepts.h>
24 #include <__cxx03/__ranges/dangling.h>
25 #include <__cxx03/__type_traits/decay.h>
26 #include <__cxx03/__utility/move.h>
27 #include <__cxx03/__utility/pair.h>
29 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
30 # pragma GCC system_header
34 #include <__cxx03/__undef_macros>
36 #if _LIBCPP_STD_VER >= 20
38 _LIBCPP_BEGIN_NAMESPACE_STD
42 template <class _InIter
, class _OutIter
>
43 using set_difference_result
= in_out_result
<_InIter
, _OutIter
>;
45 namespace __set_difference
{
48 template <input_iterator _InIter1
,
49 sentinel_for
<_InIter1
> _Sent1
,
50 input_iterator _InIter2
,
51 sentinel_for
<_InIter2
> _Sent2
,
52 weakly_incrementable _OutIter
,
54 class _Proj1
= identity
,
55 class _Proj2
= identity
>
56 requires mergeable
<_InIter1
, _InIter2
, _OutIter
, _Comp
, _Proj1
, _Proj2
>
57 _LIBCPP_HIDE_FROM_ABI
constexpr set_difference_result
<_InIter1
, _OutIter
> operator()(
65 _Proj2 __proj2
= {}) const {
66 auto __ret
= std::__set_difference
<_RangeAlgPolicy
>(
67 __first1
, __last1
, __first2
, __last2
, __result
, ranges::__make_projected_comp(__comp
, __proj1
, __proj2
));
68 return {std::move(__ret
.first
), std::move(__ret
.second
)};
71 template <input_range _Range1
,
73 weakly_incrementable _OutIter
,
75 class _Proj1
= identity
,
76 class _Proj2
= identity
>
77 requires mergeable
<iterator_t
<_Range1
>, iterator_t
<_Range2
>, _OutIter
, _Comp
, _Proj1
, _Proj2
>
78 _LIBCPP_HIDE_FROM_ABI
constexpr set_difference_result
<borrowed_iterator_t
<_Range1
>, _OutIter
>
79 operator()(_Range1
&& __range1
,
84 _Proj2 __proj2
= {}) const {
85 auto __ret
= std::__set_difference
<_RangeAlgPolicy
>(
86 ranges::begin(__range1
),
87 ranges::end(__range1
),
88 ranges::begin(__range2
),
89 ranges::end(__range2
),
91 ranges::__make_projected_comp(__comp
, __proj1
, __proj2
));
92 return {std::move(__ret
.first
), std::move(__ret
.second
)};
96 } // namespace __set_difference
98 inline namespace __cpo
{
99 inline constexpr auto set_difference
= __set_difference::__fn
{};
101 } // namespace ranges
103 _LIBCPP_END_NAMESPACE_STD
105 #endif // _LIBCPP_STD_VER >= 20
109 #endif // _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H