public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-4508] libstdc++: Change std::variant union member to empty struct
@ 2021-10-19 14:01 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2021-10-19 14:01 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:5a8832b1659e311437d25b7ec8b078be27ae54b8

commit r12-4508-g5a8832b1659e311437d25b7ec8b078be27ae54b8
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Oct 19 11:53:27 2021 +0100

    libstdc++: Change std::variant union member to empty struct
    
    This more clearly expresses the intent (a completely unused, trivial
    type) than using char. It's also consistent with the unions in
    std::optional.
    
    libstdc++-v3/ChangeLog:
    
            * include/std/variant (_Uninitialized): Use an empty struct
            for the unused union member, instead of char.

Diff:
---
 libstdc++-v3/include/std/variant | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index d18365fde22..3da7dad1e82 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -293,8 +293,10 @@ namespace __variant
       constexpr _Type&& _M_get() && noexcept
       { return std::move(_M_storage); }
 
+      struct _Empty_byte { };
+
       union {
-	char _M_nope;
+	_Empty_byte _M_empty;
 	_Type _M_storage;
       };
 #else


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-19 14:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-19 14:01 [gcc r12-4508] libstdc++: Change std::variant union member to empty struct Jonathan Wakely

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).