Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:11

0001 //===----------------------------------------------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H
0010 #define _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H
0011 
0012 #include <__algorithm/in_out_result.h>
0013 #include <__algorithm/make_projected.h>
0014 #include <__algorithm/set_difference.h>
0015 #include <__config>
0016 #include <__functional/identity.h>
0017 #include <__functional/invoke.h>
0018 #include <__functional/ranges_operations.h>
0019 #include <__iterator/concepts.h>
0020 #include <__iterator/mergeable.h>
0021 #include <__ranges/access.h>
0022 #include <__ranges/concepts.h>
0023 #include <__ranges/dangling.h>
0024 #include <__type_traits/decay.h>
0025 #include <__utility/move.h>
0026 #include <__utility/pair.h>
0027 
0028 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0029 #  pragma GCC system_header
0030 #endif
0031 
0032 _LIBCPP_PUSH_MACROS
0033 #include <__undef_macros>
0034 
0035 #if _LIBCPP_STD_VER >= 20
0036 
0037 _LIBCPP_BEGIN_NAMESPACE_STD
0038 
0039 namespace ranges {
0040 
0041 template <class _InIter, class _OutIter>
0042 using set_difference_result = in_out_result<_InIter, _OutIter>;
0043 
0044 struct __set_difference {
0045   template <input_iterator _InIter1,
0046             sentinel_for<_InIter1> _Sent1,
0047             input_iterator _InIter2,
0048             sentinel_for<_InIter2> _Sent2,
0049             weakly_incrementable _OutIter,
0050             class _Comp  = less,
0051             class _Proj1 = identity,
0052             class _Proj2 = identity>
0053     requires mergeable<_InIter1, _InIter2, _OutIter, _Comp, _Proj1, _Proj2>
0054   _LIBCPP_HIDE_FROM_ABI constexpr set_difference_result<_InIter1, _OutIter> operator()(
0055       _InIter1 __first1,
0056       _Sent1 __last1,
0057       _InIter2 __first2,
0058       _Sent2 __last2,
0059       _OutIter __result,
0060       _Comp __comp   = {},
0061       _Proj1 __proj1 = {},
0062       _Proj2 __proj2 = {}) const {
0063     auto __ret = std::__set_difference(
0064         __first1, __last1, __first2, __last2, __result, ranges::__make_projected_comp(__comp, __proj1, __proj2));
0065     return {std::move(__ret.first), std::move(__ret.second)};
0066   }
0067 
0068   template <input_range _Range1,
0069             input_range _Range2,
0070             weakly_incrementable _OutIter,
0071             class _Comp  = less,
0072             class _Proj1 = identity,
0073             class _Proj2 = identity>
0074     requires mergeable<iterator_t<_Range1>, iterator_t<_Range2>, _OutIter, _Comp, _Proj1, _Proj2>
0075   _LIBCPP_HIDE_FROM_ABI constexpr set_difference_result<borrowed_iterator_t<_Range1>, _OutIter>
0076   operator()(_Range1&& __range1,
0077              _Range2&& __range2,
0078              _OutIter __result,
0079              _Comp __comp   = {},
0080              _Proj1 __proj1 = {},
0081              _Proj2 __proj2 = {}) const {
0082     auto __ret = std::__set_difference(
0083         ranges::begin(__range1),
0084         ranges::end(__range1),
0085         ranges::begin(__range2),
0086         ranges::end(__range2),
0087         __result,
0088         ranges::__make_projected_comp(__comp, __proj1, __proj2));
0089     return {std::move(__ret.first), std::move(__ret.second)};
0090   }
0091 };
0092 
0093 inline namespace __cpo {
0094 inline constexpr auto set_difference = __set_difference{};
0095 } // namespace __cpo
0096 } // namespace ranges
0097 
0098 _LIBCPP_END_NAMESPACE_STD
0099 
0100 #endif // _LIBCPP_STD_VER >= 20
0101 
0102 _LIBCPP_POP_MACROS
0103 
0104 #endif // _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H