public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc/devel/ranger] libstdc++: Simplify constraints on std::compare_three_way
Date: Wed, 17 Jun 2020 18:26:46 +0000 (GMT)	[thread overview]
Message-ID: <20200617182646.0DFB53954424@sourceware.org> (raw)

https://gcc.gnu.org/g:f214ffb336d582a66149068a2a96b7fcf395b5de

commit f214ffb336d582a66149068a2a96b7fcf395b5de
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jan 29 13:56:49 2020 +0000

    libstdc++: Simplify constraints on std::compare_three_way
    
    The __3way_builtin_ptr_cmp concept can use three_way_comparable_with to
    check whether <=> is valid. Doing that makes it obvious that the
    disjunction on compare_three_way::operator() is redundant, because
    the second constraint subsumes the first.
    
    The workaround for PR c++/91073 can also be removed as that bug is fixed
    now.
    
            * libsupc++/compare (__detail::__3way_builtin_ptr_cmp): Use
            three_way_comparable_with.
            (__detail::__3way_cmp_with): Remove workaround for fixed bug.
            (compare_three_way::operator()): Remove redundant constraint from
            requires-clause.
            (__detail::_Synth3way::operator()): Use three_way_comparable_with
            instead of workaround.
            * testsuite/18_support/comparisons/object/93479.cc: Prune extra
            output due to simplified constraints on compare_three_way::operator().

Diff:
---
 libstdc++-v3/ChangeLog                                       | 10 ++++++++++
 libstdc++-v3/libsupc++/compare                               | 12 +++---------
 .../testsuite/18_support/comparisons/object/93479.cc         |  2 ++
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 2c3d33e96ca..e9a8a677e4c 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,15 @@
 2020-01-29  Jonathan Wakely  <jwakely@redhat.com>
 
+	* libsupc++/compare (__detail::__3way_builtin_ptr_cmp): Use
+	three_way_comparable_with.
+	(__detail::__3way_cmp_with): Remove workaround for fixed bug.
+	(compare_three_way::operator()): Remove redundant constraint from
+	requires-clause.
+	(__detail::_Synth3way::operator()): Use three_way_comparable_with
+	instead of workaround.
+	* testsuite/18_support/comparisons/object/93479.cc: Prune extra
+	output due to simplified constraints on compare_three_way::operator().
+
 	PR libstdc++/93479
 	* libsupc++/compare (__3way_builtin_ptr_cmp): Require <=> to be valid.
 	* testsuite/18_support/comparisons/object/93479.cc: New test.
diff --git a/libstdc++-v3/libsupc++/compare b/libstdc++-v3/libsupc++/compare
index aabd0c56530..a7a29ef0440 100644
--- a/libstdc++-v3/libsupc++/compare
+++ b/libstdc++-v3/libsupc++/compare
@@ -525,26 +525,20 @@ namespace std
     // BUILTIN-PTR-THREE-WAY(T, U)
     template<typename _Tp, typename _Up>
       concept __3way_builtin_ptr_cmp
-	= requires(_Tp&& __t, _Up&& __u)
-	    { static_cast<_Tp&&>(__t) <=> static_cast<_Up&&>(__u); }
+	= three_way_comparable_with<_Tp, _Up>
 	  && convertible_to<_Tp, const volatile void*>
 	  && convertible_to<_Up, const volatile void*>
 	  && ! requires(_Tp&& __t, _Up&& __u)
 	     { operator<=>(static_cast<_Tp&&>(__t), static_cast<_Up&&>(__u)); }
 	  && ! requires(_Tp&& __t, _Up&& __u)
 	     { static_cast<_Tp&&>(__t).operator<=>(static_cast<_Up&&>(__u)); };
-
-    // FIXME: workaround for PR c++/91073
-    template<typename _Tp, typename _Up>
-      concept __3way_cmp_with = three_way_comparable_with<_Tp, _Up>;
   } // namespace __detail
 
   // [cmp.object], typename compare_three_way
   struct compare_three_way
   {
     template<typename _Tp, typename _Up>
-      requires (__detail::__3way_cmp_with<_Tp, _Up>
-	  || __detail::__3way_builtin_ptr_cmp<_Tp, _Up>)
+      requires three_way_comparable_with<_Tp, _Up>
       constexpr auto
       operator()(_Tp&& __t, _Up&& __u) const noexcept
       {
@@ -919,7 +913,7 @@ namespace std
 	  { __u < __t } -> convertible_to<bool>;
 	}
 	{
-	  if constexpr (__3way_cmp_with<_Tp, _Up>)
+	  if constexpr (three_way_comparable_with<_Tp, _Up>)
 	    return __t <=> __u;
 	  else
 	    {
diff --git a/libstdc++-v3/testsuite/18_support/comparisons/object/93479.cc b/libstdc++-v3/testsuite/18_support/comparisons/object/93479.cc
index 7da1df15848..f4f0a36685b 100644
--- a/libstdc++-v3/testsuite/18_support/comparisons/object/93479.cc
+++ b/libstdc++-v3/testsuite/18_support/comparisons/object/93479.cc
@@ -42,3 +42,5 @@ test02()
   std::compare_three_way{}(x, ""); // { dg-error "no match" }
   std::compare_three_way{}("", x); // { dg-error "no match" }
 }
+
+// { dg-prune-output "in requirements with" }


                 reply	other threads:[~2020-06-17 18:26 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=20200617182646.0DFB53954424@sourceware.org \
    --to=aldyh@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@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).