[libcxx-commits] [libcxx] [libc++][NFC] Simplify the implementation of string and string_views operator== (PR #117184)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Nov 26 11:44:35 PST 2024
================
@@ -3840,36 +3835,9 @@ template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool
operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT {
-#if _LIBCPP_STD_VER >= 20
- return basic_string_view<_CharT, _Traits>(__lhs) == basic_string_view<_CharT, _Traits>(__rhs);
-#else
size_t __lhs_sz = __lhs.size();
return __lhs_sz == __rhs.size() && _Traits::compare(__lhs.data(), __rhs.data(), __lhs_sz) == 0;
-#endif
-}
-
-template <class _Allocator>
-inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool
-operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,
- const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT {
- size_t __sz = __lhs.size();
- if (__sz != __rhs.size())
- return false;
- return char_traits<char>::compare(__lhs.data(), __rhs.data(), __sz) == 0;
-}
----------------
ldionne wrote:
This is so weird. Why did we provide an operator for `char` specifically? A bit of archeology is probably needed, I assume there's a subtle reason.
https://github.com/llvm/llvm-project/pull/117184
More information about the libcxx-commits
mailing list