From patchwork Fri Apr 19 20:08:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1925673 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ehnsSIFL; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VLm1x6c95z1xrS for ; Sat, 20 Apr 2024 06:09:09 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 16C49384607A for ; Fri, 19 Apr 2024 20:09:08 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 2AC4E38460A2 for ; Fri, 19 Apr 2024 20:08:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2AC4E38460A2 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2AC4E38460A2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713557318; cv=none; b=nW+kkohTMUtg/0jp00KgmwczbJ9vtRj0mHGbscm8KP/pN/c1/TCiO3ptVTZOQ1EymUFqpZRQImagttXcG2ZYvoz6H01Lz0/jT1WyqKqM5qU1Jv9tLQgRIc+JzUeMN242+QOyPwEJd2lXccVxgQ+yTsepBM1G9wUSS1U6zbswAPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713557318; c=relaxed/simple; bh=sEUOjyEhFVyFKuefDaQVHP55pqYQtWIoRRRjt4VMmBk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=a8M5f5lWeupQI9cUJcnUbS0+gK9YHPXIUujtcyZnqJTTpOtlNN0KB1ttGYXn6LHHcveSSWqn+rosh9DK5ppASRUcbeizSodbQtGQB6PW4q+BozY94m7oR/ZU+tpXmVsbAhi6nWDKQY9MCdeiKZ06o/mrxQTVO79XrQbHUFmh40U= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713557316; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yIAlqz9MMw8N8ZCqKllR3Z8lipjmXBvtuPdiXONewiY=; b=ehnsSIFLcNGh0YUtQ4ug8Sh6XW+zJ+uaJ/4m3ycbfZ5vSmJd9lPlK+s79MeNxYfp41zD7T DgLLtSe5R54eD00d8wCSkR6FoohprytAzlOJzIy+W92fvX/jxGlaGEOugo5Gs1ylR+AJ2y 28yYSOR84CxtG4VI/HpaqZ44g2UtYpk= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-118-qvmWK9FAPweDdY30A1TDEg-1; Fri, 19 Apr 2024 16:08:35 -0400 X-MC-Unique: qvmWK9FAPweDdY30A1TDEg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2AD031C3F107; Fri, 19 Apr 2024 20:08:35 +0000 (UTC) Received: from localhost (unknown [10.42.28.238]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE6FB40005B; Fri, 19 Apr 2024 20:08:34 +0000 (UTC) From: Jonathan Wakely 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 Message-ID: <20240419200834.1500201-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org 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; } { 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 };