Back to home page

EIC code displayed by LXR

 
 

    


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

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