From patchwork Wed Apr 10 08:45:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1921850 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=i1Bv2paW; 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 4VDxRz1pnrz1yYS for ; Wed, 10 Apr 2024 18:53:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 664573858C33 for ; Wed, 10 Apr 2024 08:53:01 +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 62A1C3858C52 for ; Wed, 10 Apr 2024 08:51:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 62A1C3858C52 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 62A1C3858C52 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=1712739070; cv=none; b=o2jIUD6BLF8CJICB7ZLD5+uk8b2tMHToKhHfLwYW0VQY+zDIn3UVAddERPnR+HkdwkCxO9MHzCKmDspqIKAnQa3rj/EVYEMi2ij2n5VzIa5UC48zZ2tshrpeVHxUDd+VDgDQcf+BPm10LgFm0d5SErfa5hV3DY5pB17GSsbPlJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712739070; c=relaxed/simple; bh=xV234a6HscIIqDJE+fcg0Pd8xep3cCFWIFiFnPOVLYs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=bxwJLThC+Z5H1KlDYs3vuy9AsdZhxRbERfyh7CCxJmpbaT2d/cX24W0dcUelS+/gh7dlc1AYlkl9qtxtCzQu7o7G/KAVI6TUKQXLRNvcP9oLYyKZYlk4ilkKp/Gl3IY6qEMRJBxETvbDK3Us3mFT8LKLuoeJLWg/o2gGFbinsXA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712739062; 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: in-reply-to:in-reply-to:references:references; bh=foUj9RN20P8rQCQXZP5pJlCTCtkc6lxVc0GwHOQzeTI=; b=i1Bv2paWe15uFp9ZYjnu40nWw2R+2hsWo2s15U+guUtXvEuhfGON0yx7qX3C8XKAYQwaEQ go/ucNVgyPAqJI9wwyQvedlp9NlshaICT118ylvKK6SuBwV9hEfnjt1kFpsINUfPbkj7L5 Z4PUAjROdYRdRWG8ewB0n7+tdwod2wI= 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-56-ZRvSY48CMtGBI9iAcm89hQ-1; Wed, 10 Apr 2024 04:50:59 -0400 X-MC-Unique: ZRvSY48CMtGBI9iAcm89hQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 E63CE3800096; Wed, 10 Apr 2024 08:50:58 +0000 (UTC) Received: from localhost (unknown [10.42.28.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id B62C31C060A6; Wed, 10 Apr 2024 08:50:58 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 4/4] libstdc++: Simplify std::variant comparison operators Date: Wed, 10 Apr 2024 09:45:56 +0100 Message-ID: <20240410085039.267589-4-jwakely@redhat.com> In-Reply-To: <20240410085039.267589-1-jwakely@redhat.com> References: <20240410085039.267589-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.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=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. This is just a minor clean-up and could wait for stage 1. -- >8 -- libstdc++-v3/ChangeLog: * include/std/variant (_VARIANT_RELATION_FUNCTION_TEMPLATE): Simplify. --- libstdc++-v3/include/std/variant | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index 5ba6d9d42e3..2be0f0c1db7 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -1245,7 +1245,7 @@ namespace __variant # define _VARIANT_RELATION_FUNCTION_CONSTRAINTS(TYPES, OP) #endif -#define _VARIANT_RELATION_FUNCTION_TEMPLATE(__OP, __NAME) \ +#define _VARIANT_RELATION_FUNCTION_TEMPLATE(__OP) \ template \ _VARIANT_RELATION_FUNCTION_CONSTRAINTS(_Types, __OP) \ constexpr bool \ @@ -1262,22 +1262,20 @@ namespace __variant { \ auto& __this_mem = std::get<__rhs_index>(__lhs); \ __ret = __this_mem __OP __rhs_mem; \ + return; \ } \ - else \ - __ret = (__lhs.index() + 1) __OP (__rhs_index + 1); \ } \ - else \ - __ret = (__lhs.index() + 1) __OP (__rhs_index + 1); \ + __ret = (__lhs.index() + 1) __OP (__rhs_index + 1); \ }, __rhs); \ return __ret; \ } - _VARIANT_RELATION_FUNCTION_TEMPLATE(<, less) - _VARIANT_RELATION_FUNCTION_TEMPLATE(<=, less_equal) - _VARIANT_RELATION_FUNCTION_TEMPLATE(==, equal) - _VARIANT_RELATION_FUNCTION_TEMPLATE(!=, not_equal) - _VARIANT_RELATION_FUNCTION_TEMPLATE(>=, greater_equal) - _VARIANT_RELATION_FUNCTION_TEMPLATE(>, greater) + _VARIANT_RELATION_FUNCTION_TEMPLATE(<) + _VARIANT_RELATION_FUNCTION_TEMPLATE(<=) + _VARIANT_RELATION_FUNCTION_TEMPLATE(==) + _VARIANT_RELATION_FUNCTION_TEMPLATE(!=) + _VARIANT_RELATION_FUNCTION_TEMPLATE(>=) + _VARIANT_RELATION_FUNCTION_TEMPLATE(>) #undef _VARIANT_RELATION_FUNCTION_TEMPLATE