]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Use _M_get() in std::optional internals
authorJonathan Wakely <jwakely@redhat.com>
Tue, 23 Jul 2024 10:46:05 +0000 (11:46 +0100)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 28 Jul 2024 17:05:56 +0000 (19:05 +0200)
commit13c94d827596cb90c53e35e0c6839e10c0944d25
treeb7f2fe8fc0872c2994d24673e23605222183e458
parent5b1ead44898908123560a7e4f2be237b2ef53cb9
libstdc++: Use _M_get() in std::optional internals

Now that _base::_M_get() doesn't check the precondition, we can use
_M_get() instead of operator*() for the internal uses where we've
already checked the precondition holds.

Add a using-declaration so that we don't need to lookup _M_get in the
dependent base class, and make optional<U> a friend so that the
converting constructors and assignment operators can use the parameter's
_M_get member.

libstdc++-v3/ChangeLog:

* include/std/optional (optional): Add using-declaraction for
_Base::_M_get and declare optional<U> as friend.
(optional(const optional<U>&)): Use
_M_get instead of operator*.
(optional(optional<U>&&)): Likewise.
(operator=(const optional<U>&)): Likewise.
(operator=(optional<U>&&)): Likewise.
(and_then, tansform): Likewise.
libstdc++-v3/include/std/optional