From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 4707A3858426 for ; Wed, 2 Nov 2022 12:56:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4707A3858426 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667393804; 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=cGMJSjqAVv8i9f1Zv46OUDksVDZYlEZnozX9Y9LdFLc=; b=arhLZE/1hqOOMOTcwTzemaDDPi7RBwP4Ibmxe727Ig9UXpWoVLsYQ41tN3Be/8LHvrzB13 iImCS29koqIahP93xGeMryMKzmg6mUGMg9LcCLeQ9seM5CC2Fr7g38cikmRsi/PQFuzgc/ J1/jq4n6UabdkOeVUPOaW8KRO6rvaTA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-244-9LBjb0nLMmKhUnn7RsTIlQ-1; Wed, 02 Nov 2022 08:56:40 -0400 X-MC-Unique: 9LBjb0nLMmKhUnn7RsTIlQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B1DEA38149C2; Wed, 2 Nov 2022 12:56:39 +0000 (UTC) Received: from localhost (unknown [10.33.37.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E599492B33; Wed, 2 Nov 2022 12:56:39 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Remove unnecessary variant member in std::expected Date: Wed, 2 Nov 2022 12:56:38 +0000 Message-Id: <20221102125638.634917-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.8 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_H2,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 List-Id: Tested powerpc64le-linux. Pushed to trunk. -- >8 -- Hui Xie pointed out that we don't need a dummy member in the union, because all constructors always initialize either _M_val or _M_unex. We still need the _M_void member of the expected specialization, because the constructor has to initialize something when not using the _M_unex member. libstdc++-v3/ChangeLog: * include/std/expected (expected::_M_invalid): Remove. --- libstdc++-v3/include/std/expected | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/include/std/expected b/libstdc++-v3/include/std/expected index 3ee13aa95f6..e491ce41591 100644 --- a/libstdc++-v3/include/std/expected +++ b/libstdc++-v3/include/std/expected @@ -359,7 +359,7 @@ namespace __expected requires is_copy_constructible_v<_Tp> && is_copy_constructible_v<_Er> && (!is_trivially_copy_constructible_v<_Tp> || !is_trivially_copy_constructible_v<_Er>) - : _M_invalid(), _M_has_value(__x._M_has_value) + : _M_has_value(__x._M_has_value) { if (_M_has_value) std::construct_at(__builtin_addressof(_M_val), __x._M_val); @@ -376,7 +376,7 @@ namespace __expected requires is_move_constructible_v<_Tp> && is_move_constructible_v<_Er> && (!is_trivially_move_constructible_v<_Tp> || !is_trivially_move_constructible_v<_Er>) - : _M_invalid(), _M_has_value(__x._M_has_value) + : _M_has_value(__x._M_has_value) { if (_M_has_value) std::construct_at(__builtin_addressof(_M_val), @@ -394,7 +394,7 @@ namespace __expected expected(const expected<_Up, _Gr>& __x) noexcept(__and_v, is_nothrow_constructible<_Er, const _Gr&>>) - : _M_invalid(), _M_has_value(__x._M_has_value) + : _M_has_value(__x._M_has_value) { if (_M_has_value) std::construct_at(__builtin_addressof(_M_val), __x._M_val); @@ -410,7 +410,7 @@ namespace __expected expected(expected<_Up, _Gr>&& __x) noexcept(__and_v, is_nothrow_constructible<_Er, _Gr>>) - : _M_invalid(), _M_has_value(__x._M_has_value) + : _M_has_value(__x._M_has_value) { if (_M_has_value) std::construct_at(__builtin_addressof(_M_val), @@ -890,7 +890,6 @@ namespace __expected } union { - struct { } _M_invalid; _Tp _M_val; _Er _M_unex; }; -- 2.38.1