From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Simplify constraints on <=> for std::reference_wrapper
Date: Fri, 19 Apr 2024 21:08:21 +0100 [thread overview]
Message-ID: <20240419200834.1500201-1-jwakely@redhat.com> (raw)
Tested x86_64-linux. Pushed to trunk.
-- >8 --
Instead of constraining these overloads in terms of synth-three-way we
can just check that the value_type is less-than-comparable, which is
what synth-three-way's constraints check.
The reason that I implemented these with constraints has now been filed
as LWG 4071, so add a comment about that too.
libstdc++-v3/ChangeLog:
* include/bits/refwrap.h (operator<=>): Simplify constraints.
---
libstdc++-v3/include/bits/refwrap.h | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/libstdc++-v3/include/bits/refwrap.h b/libstdc++-v3/include/bits/refwrap.h
index fd1cc2b63e6..71ec2b297b7 100644
--- a/libstdc++-v3/include/bits/refwrap.h
+++ b/libstdc++-v3/include/bits/refwrap.h
@@ -384,23 +384,29 @@ _GLIBCXX_MEM_FN_TRAITS(&& noexcept, false_type, true_type)
&& requires { { __x.get() == __y.get() } -> convertible_to<bool>; }
{ return __x.get() == __y.get(); }
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 4071. reference_wrapper comparisons are not SFINAE-friendly
+
[[nodiscard]]
friend constexpr auto
- operator<=>(reference_wrapper __x, reference_wrapper<_Tp> __y)
- requires requires { __detail::__synth3way(__x.get(), __y.get()); }
+ operator<=>(reference_wrapper __x, reference_wrapper __y)
+ requires requires (const _Tp __t) {
+ { __t < __t } -> __detail::__boolean_testable;
+ }
{ return __detail::__synth3way(__x.get(), __y.get()); }
[[nodiscard]]
friend constexpr auto
operator<=>(reference_wrapper __x, const _Tp& __y)
- requires requires { __detail::__synth3way(__x.get(), __y); }
+ requires requires { { __y < __y } -> __detail::__boolean_testable; }
{ return __detail::__synth3way(__x.get(), __y); }
[[nodiscard]]
friend constexpr auto
operator<=>(reference_wrapper __x, reference_wrapper<const _Tp> __y)
- requires (!is_const_v<_Tp>)
- && requires { __detail::__synth3way(__x.get(), __y.get()); }
+ requires (!is_const_v<_Tp>) && requires (const _Tp __t) {
+ { __t < __t } -> __detail::__boolean_testable;
+ }
{ return __detail::__synth3way(__x.get(), __y.get()); }
#endif
};
--
2.44.0
reply other threads:[~2024-04-19 20:08 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=20240419200834.1500201-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).