Back to home page

EIC code displayed by LXR

 
 

    


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

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