[libcxx-commits] [libcxx] [libc++] Optimize ranges::equal for vector<bool>::iterator (PR #121084)
Peng Liu via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Feb 6 16:30:26 PST 2025
================
@@ -94,6 +228,32 @@ __equal_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&,
return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1));
}
+template <class _Cp,
+ bool _IC1,
+ bool _IC2,
+ class _Pred,
+ class _Proj1,
+ class _Proj2,
+ __enable_if_t<(is_same<_Pred, __equal_to>::value
+# if _LIBCPP_STD_VER >= 20
+ || is_same<_Pred, ranges::equal_to>::value
+# endif
+ ) &&
+ __desugars_to_v<__equal_tag, _Pred, bool, bool> && __is_identity<_Proj1>::value &&
+ __is_identity<_Proj2>::value,
----------------
winner245 wrote:
I've double-checked that libc++ provides the following specializations to ensure that both `std::__equal_to` and
`ranges::equal_to` desugars to `__equal_tag`:
```cpp
template <class _Tp, class _Up>
inline const bool __desugars_to_v<__equal_tag, ranges::equal_to, _Tp, _Up> = true;
template <class _Tp, class _Up>
inline const bool __desugars_to_v<__equal_tag, __equal_to, _Tp, _Up> = true;
```
So this simplifies the SFINAE constraint as suggested.
https://github.com/llvm/llvm-project/pull/121084
More information about the libcxx-commits
mailing list