public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Seija K." <doremylover123@gmail.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	 "libstdc++@gcc.gnu.org" <libstdc++@gcc.gnu.org>
Subject: [PATCH] PR libstdc++/98842: Fixed Constraints on operator<=>(optional,  U)
Date: Thu, 3 Jun 2021 12:25:30 -0400	[thread overview]
Message-ID: <CAA42iKzcx9dfs8-jfEwicV+SCmpaMuRo--NP0dFQfiUca+cqZA@mail.gmail.com> (raw)

The original operator was underconstrained. _Up needs to fulfill
compare_three_way_result,
as mentioned in this bug report
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98842

diff --git a/libstdc++-v3/include/std/optional
b/libstdc++-v3/include/std/optional
index 8b9e038e6e510..9e61c1b2cbfbd 100644
--- a/libstdc++-v3/include/std/optional
+++ b/libstdc++-v3/include/std/optional
@@ -1234,7 +1234,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return !__rhs || __lhs >= *__rhs; }

 #ifdef __cpp_lib_three_way_comparison
-  template<typename _Tp, typename _Up>
+  template<typename _Tp, three_way_comparable_with<_Tp> _Up>
     constexpr compare_three_way_result_t<_Tp, _Up>
     operator<=>(const optional<_Tp>& __x, const _Up& __v)
     { return bool(__x) ? *__x <=> __v : strong_ordering::less; }

             reply	other threads:[~2021-06-03 16:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-03 16:25 Seija K. [this message]
2021-06-04 20:41 ` Jonathan Wakely
2021-06-07 15:29   ` Jonathan Wakely
2021-06-13 21:59     ` Seija K.

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=CAA42iKzcx9dfs8-jfEwicV+SCmpaMuRo--NP0dFQfiUca+cqZA@mail.gmail.com \
    --to=doremylover123@gmail.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).