]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Use concepts to simplify std::optional base classes
authorJonathan Wakely <jwakely@redhat.com>
Mon, 22 Jul 2024 19:40:17 +0000 (20:40 +0100)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 28 Jul 2024 17:05:56 +0000 (19:05 +0200)
commita9273a2991a74421f4627145f520a1eaf37736c7
tree077283aac62461182399b7ab16719fd0265f307d
parent13c94d827596cb90c53e35e0c6839e10c0944d25
libstdc++: Use concepts to simplify std::optional base classes

In C++20 mode we can simplify some of the std::optional base class
hierarchy using concepts. We can overload the destructor and copy
constructor and move constructor with a trivial defaulted version and a
constrained non-trivial version. This allows us to remove some class
template partial specializations that were used to conditionally define
those special members as trivial or non-trivial. This should not change
any semantics, but should be less work for the compiler, due to not
needing to match partial specializations, and completely removing one
level of the inheritance hierarchy.

libstdc++-v3/ChangeLog:

* include/std/optional (_Optional_payload_base::_Storage)
[C++20]: Define constrained non-trivial destructor.
(_Optional_payload_base::_Storage<U, false>) [C++20]: Do not
define partial specialization when primary template has
constrained destructor.
(_Optional_base) [C++20]: Define constrained trivial copy and
move cons and move constructors. Define payload accessors here
instead of inheriting them from _Optional_base_impl.
(_Optional_base_impl, _Optional_base<T, false, true>)
(_Optional_base<T, true, false>, _Optional_base<T, true, true>)
[C++20]: Do not define.
libstdc++-v3/include/std/optional