From patchwork Thu Aug 4 12:31:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 56541 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5EB62385084D for ; Thu, 4 Aug 2022 12:32:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5EB62385084D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1659616330; bh=tPnCemrfBOhyEepOhqRBfGd4lCuTRsnl9Zv+HYP8y4g=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=DuvDw+9H2Cs75kCAMmCfP71RYP8CMMtDBFGTSLSUPP1CmevuXBc/eFrX65BBiX6qs N0XCaqWzvYSp/RYCwzdxXDW+JVDUSr4TyP50ybRkVjq7GACSWzBTBmw/He6fwZYLqr lchV1hYCCPCNUu+lZr3Hx+QELoRLE5sHaJcbr0BU= 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 15C453856DE7 for ; Thu, 4 Aug 2022 12:31:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 15C453856DE7 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-120-5JYM-s3OMA2FC47tR_OcOA-1; Thu, 04 Aug 2022 08:31:11 -0400 X-MC-Unique: 5JYM-s3OMA2FC47tR_OcOA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8966A101A54E; Thu, 4 Aug 2022 12:31:11 +0000 (UTC) Received: from localhost (unknown [10.33.36.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 508A82166B2A; Thu, 4 Aug 2022 12:31:11 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Rename data members of std::unexpected and std::bad_expected_access Date: Thu, 4 Aug 2022 13:31:10 +0100 Message-Id: <20220804123110.726590-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.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, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Tested powerpc64le-linux, pushed to trunk. -- >8 -- The P2549R1 paper was accepted for C++23. I already implemented it for our , but I didn't rename the private daata members, only the public member functions. This renames the data members for consistency with the working draft. libstdc++-v3/ChangeLog: * include/std/expected (unexpected::_M_val): Rename to _M_unex. (bad_expected_access::_M_val): Likewise. --- libstdc++-v3/include/std/expected | 32 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/libstdc++-v3/include/std/expected b/libstdc++-v3/include/std/expected index 3446d6dbaed..3ee13aa95f6 100644 --- a/libstdc++-v3/include/std/expected +++ b/libstdc++-v3/include/std/expected @@ -95,32 +95,32 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION class bad_expected_access : public bad_expected_access { public: explicit - bad_expected_access(_Er __e) : _M_val(std::move(__e)) { } + bad_expected_access(_Er __e) : _M_unex(std::move(__e)) { } // XXX const char* what() const noexcept override; [[nodiscard]] _Er& error() & noexcept - { return _M_val; } + { return _M_unex; } [[nodiscard]] const _Er& error() const & noexcept - { return _M_val; } + { return _M_unex; } [[nodiscard]] _Er&& error() && noexcept - { return std::move(_M_val); } + { return std::move(_M_unex); } [[nodiscard]] const _Er&& error() const && noexcept - { return std::move(_M_val); } + { return std::move(_M_unex); } private: - _Er _M_val; + _Er _M_unex; }; /// Tag type for constructing unexpected values in a std::expected @@ -175,7 +175,7 @@ namespace __expected constexpr explicit unexpected(_Err&& __e) noexcept(is_nothrow_constructible_v<_Er, _Err>) - : _M_val(std::forward<_Err>(__e)) + : _M_unex(std::forward<_Err>(__e)) { } template @@ -183,7 +183,7 @@ namespace __expected constexpr explicit unexpected(in_place_t, _Args&&... __args) noexcept(is_nothrow_constructible_v<_Er, _Args...>) - : _M_val(std::forward<_Args>(__args)...) + : _M_unex(std::forward<_Args>(__args)...) { } template @@ -192,7 +192,7 @@ namespace __expected unexpected(in_place_t, initializer_list<_Up> __il, _Args&&... __args) noexcept(is_nothrow_constructible_v<_Er, initializer_list<_Up>&, _Args...>) - : _M_val(__il, std::forward<_Args>(__args)...) + : _M_unex(__il, std::forward<_Args>(__args)...) { } constexpr unexpected& operator=(const unexpected&) = default; @@ -201,33 +201,33 @@ namespace __expected [[nodiscard]] constexpr const _Er& - error() const & noexcept { return _M_val; } + error() const & noexcept { return _M_unex; } [[nodiscard]] constexpr _Er& - error() & noexcept { return _M_val; } + error() & noexcept { return _M_unex; } [[nodiscard]] constexpr const _Er&& - error() const && noexcept { return std::move(_M_val); } + error() const && noexcept { return std::move(_M_unex); } [[nodiscard]] constexpr _Er&& - error() && noexcept { return std::move(_M_val); } + error() && noexcept { return std::move(_M_unex); } constexpr void swap(unexpected& __other) noexcept(is_nothrow_swappable_v<_Er>) { static_assert( is_swappable_v<_Er> ); using std::swap; - swap(_M_val, __other._M_val); + swap(_M_unex, __other._M_unex); } template [[nodiscard]] friend constexpr bool operator==(const unexpected& __x, const unexpected<_Err>& __y) - { return __x._M_val == __y.error(); } + { return __x._M_unex == __y.error(); } friend constexpr void swap(unexpected& __x, unexpected& __y) @@ -236,7 +236,7 @@ namespace __expected { __x.swap(__y); } private: - _Er _M_val; + _Er _M_unex; }; template unexpected(_Er) -> unexpected<_Er>;