From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Simplify std::string_view comparisons (LWG 3950)
Date: Sat, 11 Nov 2023 00:45:11 +0000 [thread overview]
Message-ID: <20231111004515.78648-1-jwakely@redhat.com> (raw)
Tested x86_64-linux. Pushed to trunk.
-- >8 --
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).
---
libstdc++-v3/include/std/string_view | 22 +++++++---------------
1 file changed, 7 insertions(+), 15 deletions(-)
diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view
index 9deae25f712..cf288ed3a36 100644
--- a/libstdc++-v3/include/std/string_view
+++ b/libstdc++-v3/include/std/string_view
@@ -602,13 +602,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// deduction and the other argument gets implicitly converted to the deduced
// type (see N3766).
- 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
@@ -618,14 +611,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return __x.size() == __y.size() && __x.compare(__y) == 0; }
#if __cpp_lib_three_way_comparison
- template<typename _CharT, typename _Traits>
- [[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
@@ -635,6 +620,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
-> decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
{ return __detail::__char_traits_cmp_cat<_Traits>(__x.compare(__y)); }
#else
+ 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
--
2.41.0
reply other threads:[~2023-11-11 0:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231111004515.78648-1-jwakely@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).