From patchwork Thu Jul 25 22:12:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1964924 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=Mrt5YdRN; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4WVQBV0JmNz1yY9 for ; Fri, 26 Jul 2024 08:13:22 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4635E385C6D3 for ; Thu, 25 Jul 2024 22:13:20 +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 ESMTP id 9B6353858420 for ; Thu, 25 Jul 2024 22:12:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9B6353858420 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 9B6353858420 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=1721945572; cv=none; b=FO04kg+NBbkg28fyPkxwAN3Ai7FlrQVNl2V68lPWy83AY5iyHi5c0he192lSNlXEBNVTWV4pcxZPD05AvK1wYDCnf8HKszbEqZK1v2E3UQIX/zB4IPnOerimiVMxIGEMRBsY7rFzPfknbcxun5QMJotkxXSmfAwb2EVku4KTx1U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721945572; c=relaxed/simple; bh=zawvZURVg6pF9LBitaTlWWwj7BRAKQTPbrVn8bxmxVs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kiVS1sMQcVmLcncf8QsNKykz8hjnzYN2HZqmv1PJoLmylXd5GtrKhhMX4hNaWOcdeuUtbj7jz/iI9uo1W6rAAs2YfSFSIFf83i4UF9kxgieZVEwmOQRtv+jbAG1JBzpIWPhTmfqDuCqDZyJvK4SF51dPRhg3MTjcOeU3IYncLWo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721945570; 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=+iG7KIFrVGbsg1Wr+VGTWECIt8w3FXfo74G+ObB2xBM=; b=Mrt5YdRN31CRIZbvAISZPo0omYHadT+PzXC6B9NQbrlJEDaCAnjzIOU9BiUCY9PEVm9Z88 PsXmHF/mCrTIqYJ2numd8+yPFA3iMGTd6I1jW36ZzXRUb6CHoUpQlMNZQpQGDVj5eYNGm+ KFmC0UDJ7HOWTFYs/XSakLRm4a7f0R0= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-402-ps1ny3YZPtOLeVspPhW9fg-1; Thu, 25 Jul 2024 18:12:47 -0400 X-MC-Unique: ps1ny3YZPtOLeVspPhW9fg-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0713919560B3; Thu, 25 Jul 2024 22:12:46 +0000 (UTC) Received: from localhost (unknown [10.42.28.14]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 74C79300019A; Thu, 25 Jul 2024 22:12:42 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Reorder template params of std::optional comparisons (LWG 2945) Date: Thu, 25 Jul 2024 23:12:26 +0100 Message-ID: <20240725221241.151099-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 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=unavailable 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 -- libstdc++-v3/ChangeLog: * include/std/optional: Reorder parameters in comparison operators as per LWG 2945. --- libstdc++-v3/include/std/optional | 36 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional index 2cc0221865e..4694d594f98 100644 --- a/libstdc++-v3/include/std/optional +++ b/libstdc++-v3/include/std/optional @@ -1601,10 +1601,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __lhs && *__lhs == __rhs; } template - _REQUIRES_NOT_OPTIONAL(_Up) + _REQUIRES_NOT_OPTIONAL(_Tp) constexpr auto - operator==(const _Up& __lhs, const optional<_Tp>& __rhs) - -> __optional_eq_t<_Up, _Tp> + operator== [[nodiscard]] (const _Tp& __lhs, const optional<_Up>& __rhs) + -> __optional_eq_t<_Tp, _Up> { return __rhs && __lhs == *__rhs; } template @@ -1615,10 +1615,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return !__lhs || *__lhs != __rhs; } template - _REQUIRES_NOT_OPTIONAL(_Up) + _REQUIRES_NOT_OPTIONAL(_Tp) constexpr auto - operator!= [[nodiscard]] (const _Up& __lhs, const optional<_Tp>& __rhs) - -> __optional_ne_t<_Up, _Tp> + operator!= [[nodiscard]] (const _Tp& __lhs, const optional<_Up>& __rhs) + -> __optional_ne_t<_Tp, _Up> { return !__rhs || __lhs != *__rhs; } template @@ -1629,10 +1629,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return !__lhs || *__lhs < __rhs; } template - _REQUIRES_NOT_OPTIONAL(_Up) + _REQUIRES_NOT_OPTIONAL(_Tp) constexpr auto - operator< [[nodiscard]] (const _Up& __lhs, const optional<_Tp>& __rhs) - -> __optional_lt_t<_Up, _Tp> + operator< [[nodiscard]] (const _Tp& __lhs, const optional<_Up>& __rhs) + -> __optional_lt_t<_Tp, _Up> { return __rhs && __lhs < *__rhs; } template @@ -1643,10 +1643,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __lhs && *__lhs > __rhs; } template - _REQUIRES_NOT_OPTIONAL(_Up) + _REQUIRES_NOT_OPTIONAL(_Tp) constexpr auto - operator> [[nodiscard]] (const _Up& __lhs, const optional<_Tp>& __rhs) - -> __optional_gt_t<_Up, _Tp> + operator> [[nodiscard]] (const _Tp& __lhs, const optional<_Up>& __rhs) + -> __optional_gt_t<_Tp, _Up> { return !__rhs || __lhs > *__rhs; } template @@ -1657,10 +1657,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return !__lhs || *__lhs <= __rhs; } template - _REQUIRES_NOT_OPTIONAL(_Up) + _REQUIRES_NOT_OPTIONAL(_Tp) constexpr auto - operator<= [[nodiscard]] (const _Up& __lhs, const optional<_Tp>& __rhs) - -> __optional_le_t<_Up, _Tp> + operator<= [[nodiscard]] (const _Tp& __lhs, const optional<_Up>& __rhs) + -> __optional_le_t<_Tp, _Up> { return __rhs && __lhs <= *__rhs; } template @@ -1671,10 +1671,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __lhs && *__lhs >= __rhs; } template - _REQUIRES_NOT_OPTIONAL(_Up) + _REQUIRES_NOT_OPTIONAL(_Tp) constexpr auto - operator>= [[nodiscard]] (const _Up& __lhs, const optional<_Tp>& __rhs) - -> __optional_ge_t<_Up, _Tp> + operator>= [[nodiscard]] (const _Tp& __lhs, const optional<_Up>& __rhs) + -> __optional_ge_t<_Tp, _Up> { return !__rhs || __lhs >= *__rhs; } #ifdef __cpp_lib_three_way_comparison