aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2023-11-10 19:18:57 +0000
committerJonathan Wakely <jwakely@redhat.com>2023-11-11 00:41:09 +0000
commitf7251b7886c47cbd5c9ffb217eb9849f023f76da (patch)
treecd6a5fb2603c7d381dd5b0180d06c24545b34e94
parent7c02efd45f5e727ab8a1b397bce8817f4ab65954 (diff)
downloadgcc-f7251b7886c47cbd5c9ffb217eb9849f023f76da.zip
gcc-f7251b7886c47cbd5c9ffb217eb9849f023f76da.tar.gz
gcc-f7251b7886c47cbd5c9ffb217eb9849f023f76da.tar.bz2
libstdc++: Simplify std::string_view comparisons (LWG 3950)
LWG 3950 points out that the comparisons of std::basic_string_view can be simplified to just a single overload of operator== and a single overload of operator<=>. Those overloads work fine for homogeneous comparisons of two string view objects. libstdc++-v3/ChangeLog: * include/std/string_view (operator==, operator<=>): Remove redundant overloads (LWG 3950).
-rw-r--r--libstdc++-v3/include/std/string_view22
1 files changed, 7 insertions, 15 deletions
diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view
index 9deae25..cf288ed3a 100644
--- a/libstdc++-v3/include/std/string_view
+++ b/libstdc++-v3/include/std/string_view
@@ -606,13 +606,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
[[nodiscard]]
constexpr bool
operator==(basic_string_view<_CharT, _Traits> __x,
- basic_string_view<_CharT, _Traits> __y) noexcept
- { return __x.size() == __y.size() && __x.compare(__y) == 0; }
-
- template<typename _CharT, typename _Traits>
- [[nodiscard]]
- constexpr bool
- operator==(basic_string_view<_CharT, _Traits> __x,
__type_identity_t<basic_string_view<_CharT, _Traits>> __y)
noexcept
{ return __x.size() == __y.size() && __x.compare(__y) == 0; }
@@ -622,14 +615,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
[[nodiscard]]
constexpr auto
operator<=>(basic_string_view<_CharT, _Traits> __x,
- basic_string_view<_CharT, _Traits> __y) noexcept
- -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
- { return __detail::__char_traits_cmp_cat<_Traits>(__x.compare(__y)); }
-
- template<typename _CharT, typename _Traits>
- [[nodiscard]]
- constexpr auto
- operator<=>(basic_string_view<_CharT, _Traits> __x,
__type_identity_t<basic_string_view<_CharT, _Traits>> __y)
noexcept
-> decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
@@ -638,6 +623,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits>
[[nodiscard]]
constexpr bool
+ operator==(basic_string_view<_CharT, _Traits> __x,
+ basic_string_view<_CharT, _Traits> __y) noexcept
+ { return __x.size() == __y.size() && __x.compare(__y) == 0; }
+
+ template<typename _CharT, typename _Traits>
+ [[nodiscard]]
+ constexpr bool
operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.size() == __y.size() && __x.compare(__y) == 0; }