[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 13:07:11 PST 2024
================
@@ -755,51 +758,32 @@ operator==(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _
return __lhs.compare(__rhs) == 0;
}
-// The dummy default template parameters are used to work around a MSVC issue with mangling, see VSO-409326 for details.
-// This applies to the other sufficient overloads below for the other comparison operators.
-template <class _CharT, class _Traits, int = 1>
-_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
-operator==(basic_string_view<_CharT, _Traits> __lhs,
- __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT {
- if (__lhs.size() != __rhs.size())
- return false;
- return __lhs.compare(__rhs) == 0;
-}
-
template <class _CharT, class _Traits, int = 2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
operator==(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
- if (__lhs.size() != __rhs.size())
- return false;
- return __lhs.compare(__rhs) == 0;
+ return __lhs == __rhs;
----------------
ldionne wrote:
I must be missing the point of the `__type_identity` argument here. It seems to be central to my misunderstanding.
https://github.com/llvm/llvm-project/pull/117184
More information about the libcxx-commits
mailing list