Back to home page

EIC code displayed by LXR

 
 

    


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

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_INCLUDES_H
0010 #define _LIBCPP___CXX03___ALGORITHM_INCLUDES_H
0011 
0012 #include <__cxx03/__algorithm/comp.h>
0013 #include <__cxx03/__algorithm/comp_ref_type.h>
0014 #include <__cxx03/__config>
0015 #include <__cxx03/__functional/identity.h>
0016 #include <__cxx03/__functional/invoke.h>
0017 #include <__cxx03/__iterator/iterator_traits.h>
0018 #include <__cxx03/__type_traits/is_callable.h>
0019 #include <__cxx03/__utility/move.h>
0020 
0021 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0022 #  pragma GCC system_header
0023 #endif
0024 
0025 _LIBCPP_PUSH_MACROS
0026 #include <__cxx03/__undef_macros>
0027 
0028 _LIBCPP_BEGIN_NAMESPACE_STD
0029 
0030 template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Comp, class _Proj1, class _Proj2>
0031 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __includes(
0032     _Iter1 __first1,
0033     _Sent1 __last1,
0034     _Iter2 __first2,
0035     _Sent2 __last2,
0036     _Comp&& __comp,
0037     _Proj1&& __proj1,
0038     _Proj2&& __proj2) {
0039   for (; __first2 != __last2; ++__first1) {
0040     if (__first1 == __last1 ||
0041         std::__invoke(__comp, std::__invoke(__proj2, *__first2), std::__invoke(__proj1, *__first1)))
0042       return false;
0043     if (!std::__invoke(__comp, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
0044       ++__first2;
0045   }
0046   return true;
0047 }
0048 
0049 template <class _InputIterator1, class _InputIterator2, class _Compare>
0050 _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
0051 includes(_InputIterator1 __first1,
0052          _InputIterator1 __last1,
0053          _InputIterator2 __first2,
0054          _InputIterator2 __last2,
0055          _Compare __comp) {
0056   static_assert(
0057       __is_callable<_Compare, decltype(*__first1), decltype(*__first2)>::value, "Comparator has to be callable");
0058 
0059   return std::__includes(
0060       std::move(__first1),
0061       std::move(__last1),
0062       std::move(__first2),
0063       std::move(__last2),
0064       static_cast<__comp_ref_type<_Compare> >(__comp),
0065       __identity(),
0066       __identity());
0067 }
0068 
0069 template <class _InputIterator1, class _InputIterator2>
0070 _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
0071 includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
0072   return std::includes(std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __less<>());
0073 }
0074 
0075 _LIBCPP_END_NAMESPACE_STD
0076 
0077 _LIBCPP_POP_MACROS
0078 
0079 #endif // _LIBCPP___CXX03___ALGORITHM_INCLUDES_H