Back to home page

EIC code displayed by LXR

 
 

    


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

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_SET_DIFFERENCE_H
0010 #define _LIBCPP___ALGORITHM_SET_DIFFERENCE_H
0011 
0012 #include <__algorithm/comp.h>
0013 #include <__algorithm/comp_ref_type.h>
0014 #include <__algorithm/copy.h>
0015 #include <__config>
0016 #include <__functional/identity.h>
0017 #include <__iterator/iterator_traits.h>
0018 #include <__type_traits/remove_cvref.h>
0019 #include <__utility/move.h>
0020 #include <__utility/pair.h>
0021 
0022 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0023 #  pragma GCC system_header
0024 #endif
0025 
0026 _LIBCPP_PUSH_MACROS
0027 #include <__undef_macros>
0028 
0029 _LIBCPP_BEGIN_NAMESPACE_STD
0030 
0031 template <class _Comp, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
0032 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__remove_cvref_t<_InIter1>, __remove_cvref_t<_OutIter> >
0033 __set_difference(
0034     _InIter1&& __first1, _Sent1&& __last1, _InIter2&& __first2, _Sent2&& __last2, _OutIter&& __result, _Comp&& __comp) {
0035   while (__first1 != __last1 && __first2 != __last2) {
0036     if (__comp(*__first1, *__first2)) {
0037       *__result = *__first1;
0038       ++__first1;
0039       ++__result;
0040     } else if (__comp(*__first2, *__first1)) {
0041       ++__first2;
0042     } else {
0043       ++__first1;
0044       ++__first2;
0045     }
0046   }
0047   return std::__copy(std::move(__first1), std::move(__last1), std::move(__result));
0048 }
0049 
0050 template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
0051 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_difference(
0052     _InputIterator1 __first1,
0053     _InputIterator1 __last1,
0054     _InputIterator2 __first2,
0055     _InputIterator2 __last2,
0056     _OutputIterator __result,
0057     _Compare __comp) {
0058   return std::__set_difference<__comp_ref_type<_Compare> >(__first1, __last1, __first2, __last2, __result, __comp)
0059       .second;
0060 }
0061 
0062 template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
0063 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_difference(
0064     _InputIterator1 __first1,
0065     _InputIterator1 __last1,
0066     _InputIterator2 __first2,
0067     _InputIterator2 __last2,
0068     _OutputIterator __result) {
0069   return std::__set_difference(__first1, __last1, __first2, __last2, __result, __less<>()).second;
0070 }
0071 
0072 _LIBCPP_END_NAMESPACE_STD
0073 
0074 _LIBCPP_POP_MACROS
0075 
0076 #endif // _LIBCPP___ALGORITHM_SET_DIFFERENCE_H