Back to home page

EIC code displayed by LXR

 
 

    


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

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