@@ -69,20 +69,6 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first
69
69
}
70
70
71
71
#if _LIBCPP_STD_VER >= 14
72
- template <class _BinaryPredicate , class _InputIterator1 , class _InputIterator2 >
73
- inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
74
- __equal (_InputIterator1 __first1,
75
- _InputIterator1 __last1,
76
- _InputIterator2 __first2,
77
- _InputIterator2 __last2,
78
- _BinaryPredicate __pred,
79
- input_iterator_tag,
80
- input_iterator_tag) {
81
- for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void )++__first2)
82
- if (!__pred (*__first1, *__first2))
83
- return false ;
84
- return __first1 == __last1 && __first2 == __last2;
85
- }
86
72
87
73
template <class _Iter1 , class _Sent1 , class _Iter2 , class _Sent2 , class _Pred , class _Proj1 , class _Proj2 >
88
74
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_impl (
@@ -110,17 +96,18 @@ __equal_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&,
110
96
return std::__constexpr_memcmp_equal (__first1, __first2, __element_count (__last1 - __first1));
111
97
}
112
98
113
- template <class _BinaryPredicate , class _RandomAccessIterator1 , class _RandomAccessIterator2 >
114
- inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
115
- __equal (_RandomAccessIterator1 __first1,
116
- _RandomAccessIterator1 __last1,
117
- _RandomAccessIterator2 __first2,
118
- _RandomAccessIterator2 __last2,
119
- _BinaryPredicate __pred,
120
- random_access_iterator_tag,
121
- random_access_iterator_tag) {
122
- if (std::distance (__first1, __last1) != std::distance (__first2, __last2))
123
- return false ;
99
+ template <class _InputIterator1 , class _InputIterator2 , class _BinaryPredicate >
100
+ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
101
+ equal (_InputIterator1 __first1,
102
+ _InputIterator1 __last1,
103
+ _InputIterator2 __first2,
104
+ _InputIterator2 __last2,
105
+ _BinaryPredicate __pred) {
106
+ if constexpr (__has_random_access_iterator_category<_InputIterator1>::value &&
107
+ __has_random_access_iterator_category<_InputIterator2>::value) {
108
+ if (std::distance (__first1, __last1) != std::distance (__first2, __last2))
109
+ return false ;
110
+ }
124
111
__identity __proj;
125
112
return std::__equal_impl (
126
113
std::__unwrap_iter (__first1),
@@ -132,36 +119,13 @@ __equal(_RandomAccessIterator1 __first1,
132
119
__proj);
133
120
}
134
121
135
- template <class _InputIterator1 , class _InputIterator2 , class _BinaryPredicate >
136
- _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
137
- equal (_InputIterator1 __first1,
138
- _InputIterator1 __last1,
139
- _InputIterator2 __first2,
140
- _InputIterator2 __last2,
141
- _BinaryPredicate __pred) {
142
- return std::__equal<_BinaryPredicate&>(
143
- __first1,
144
- __last1,
145
- __first2,
146
- __last2,
147
- __pred,
148
- typename iterator_traits<_InputIterator1>::iterator_category (),
149
- typename iterator_traits<_InputIterator2>::iterator_category ());
150
- }
151
-
152
122
template <class _InputIterator1 , class _InputIterator2 >
153
123
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
154
124
equal (_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
155
- return std::__equal (
156
- __first1,
157
- __last1,
158
- __first2,
159
- __last2,
160
- __equal_to (),
161
- typename iterator_traits<_InputIterator1>::iterator_category (),
162
- typename iterator_traits<_InputIterator2>::iterator_category ());
125
+ return std::equal (__first1, __last1, __first2, __last2, __equal_to ());
163
126
}
164
- #endif
127
+
128
+ #endif // _LIBCPP_STD_VER >= 14
165
129
166
130
_LIBCPP_END_NAMESPACE_STD
167
131
0 commit comments