Back to home page

EIC code displayed by LXR

 
 

    


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

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_RANGES_EQUAL_H
0010 #define _LIBCPP___CXX03___ALGORITHM_RANGES_EQUAL_H
0011 
0012 #include <__cxx03/__algorithm/equal.h>
0013 #include <__cxx03/__algorithm/unwrap_range.h>
0014 #include <__cxx03/__config>
0015 #include <__cxx03/__functional/identity.h>
0016 #include <__cxx03/__functional/invoke.h>
0017 #include <__cxx03/__functional/ranges_operations.h>
0018 #include <__cxx03/__iterator/concepts.h>
0019 #include <__cxx03/__iterator/distance.h>
0020 #include <__cxx03/__iterator/indirectly_comparable.h>
0021 #include <__cxx03/__ranges/access.h>
0022 #include <__cxx03/__ranges/concepts.h>
0023 #include <__cxx03/__utility/move.h>
0024 
0025 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0026 #  pragma GCC system_header
0027 #endif
0028 
0029 _LIBCPP_PUSH_MACROS
0030 #include <__cxx03/__undef_macros>
0031 
0032 #if _LIBCPP_STD_VER >= 20
0033 
0034 _LIBCPP_BEGIN_NAMESPACE_STD
0035 
0036 namespace ranges {
0037 namespace __equal {
0038 struct __fn {
0039   template <input_iterator _Iter1,
0040             sentinel_for<_Iter1> _Sent1,
0041             input_iterator _Iter2,
0042             sentinel_for<_Iter2> _Sent2,
0043             class _Pred  = ranges::equal_to,
0044             class _Proj1 = identity,
0045             class _Proj2 = identity>
0046     requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
0047   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
0048       _Iter1 __first1,
0049       _Sent1 __last1,
0050       _Iter2 __first2,
0051       _Sent2 __last2,
0052       _Pred __pred   = {},
0053       _Proj1 __proj1 = {},
0054       _Proj2 __proj2 = {}) const {
0055     if constexpr (sized_sentinel_for<_Sent1, _Iter1> && sized_sentinel_for<_Sent2, _Iter2>) {
0056       if (__last1 - __first1 != __last2 - __first2)
0057         return false;
0058     }
0059     auto __unwrapped1 = std::__unwrap_range(std::move(__first1), std::move(__last1));
0060     auto __unwrapped2 = std::__unwrap_range(std::move(__first2), std::move(__last2));
0061     return std::__equal_impl(
0062         std::move(__unwrapped1.first),
0063         std::move(__unwrapped1.second),
0064         std::move(__unwrapped2.first),
0065         std::move(__unwrapped2.second),
0066         __pred,
0067         __proj1,
0068         __proj2);
0069   }
0070 
0071   template <input_range _Range1,
0072             input_range _Range2,
0073             class _Pred  = ranges::equal_to,
0074             class _Proj1 = identity,
0075             class _Proj2 = identity>
0076     requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
0077   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
0078       _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
0079     if constexpr (sized_range<_Range1> && sized_range<_Range2>) {
0080       if (ranges::distance(__range1) != ranges::distance(__range2))
0081         return false;
0082     }
0083     auto __unwrapped1 = std::__unwrap_range(ranges::begin(__range1), ranges::end(__range1));
0084     auto __unwrapped2 = std::__unwrap_range(ranges::begin(__range2), ranges::end(__range2));
0085     return std::__equal_impl(
0086         std::move(__unwrapped1.first),
0087         std::move(__unwrapped1.second),
0088         std::move(__unwrapped2.first),
0089         std::move(__unwrapped2.second),
0090         __pred,
0091         __proj1,
0092         __proj2);
0093     return false;
0094   }
0095 };
0096 } // namespace __equal
0097 
0098 inline namespace __cpo {
0099 inline constexpr auto equal = __equal::__fn{};
0100 } // namespace __cpo
0101 } // namespace ranges
0102 
0103 _LIBCPP_END_NAMESPACE_STD
0104 
0105 #endif // _LIBCPP_STD_VER >= 20
0106 
0107 _LIBCPP_POP_MACROS
0108 
0109 #endif // _LIBCPP___CXX03___ALGORITHM_RANGES_EQUAL_H