From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id E72C63849ACF; Fri, 19 Apr 2024 20:08:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E72C63849ACF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713557300; bh=7JZ5IA0cBEQ1dWEv8aeg18cZ7owOfVOCt1XjzoYL0ig=; h=From:To:Subject:Date:From; b=VLjVkLo/b1exn3Sz13bDWFJL1cFVt8HeYnzvEeGIG0Jtn2nQ5dWXnvB1+/Ptj9Z7r W+nPUh/lOzIGGrmxl1JNoZRU1jHKEx6rzqxnkN/KRM0la1WXE1iqLFAd3YKSgLQzQS Iwu4o+X0zOczuNNnqfzMMQpO6ZM10U/iNEo/yY68= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r14-10044] libstdc++: Simplify constraints on <=> for std::reference_wrapper X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: eed7fb1b2fe72150cd6af10dd3b8f7fc4f0a4da1 X-Git-Newrev: d86472a6f041ccf3d1be0cf6bb15d1e0ad8f6dbe Message-Id: <20240419200820.E72C63849ACF@sourceware.org> Date: Fri, 19 Apr 2024 20:08:20 +0000 (GMT) List-Id: https://gcc.gnu.org/g:d86472a6f041ccf3d1be0cf6bb15d1e0ad8f6dbe commit r14-10044-gd86472a6f041ccf3d1be0cf6bb15d1e0ad8f6dbe Author: Jonathan Wakely Date: Fri Apr 19 17:42:04 2024 +0100 libstdc++: Simplify constraints on <=> for std::reference_wrapper 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. Diff: --- 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; } { 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 __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 };