public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r12-8665] libstdc++: Rename data members of std::unexpected and std::bad_expected_access
Date: Fri,  5 Aug 2022 12:32:17 +0000 (GMT)	[thread overview]
Message-ID: <20220805123217.6B278385AC2D@sourceware.org> (raw)

https://gcc.gnu.org/g:0b4d2f5e7b446477abe6165f7b3a86616cf95ce0

commit r12-8665-g0b4d2f5e7b446477abe6165f7b3a86616cf95ce0
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Aug 4 10:20:18 2022 +0100

    libstdc++: Rename data members of std::unexpected and std::bad_expected_access
    
    The P2549R1 paper was accepted for C++23. I already implemented it for
    our <expected>, 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.
    
    (cherry picked from commit 07c7ee4d2d42f4728928556dbbe0700f9a13db90)

Diff:
---
 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<void> {
     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<typename... _Args>
@@ -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<typename _Up, typename... _Args>
@@ -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<typename _Err>
 	[[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<typename _Er> unexpected(_Er) -> unexpected<_Er>;


                 reply	other threads:[~2022-08-05 12:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220805123217.6B278385AC2D@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).