std.typecons: make Nullable payload void initialized

Signed-off-by: Luís Ferreira <contact@lsferreira.net>
This commit is contained in:
Luís Ferreira 2021-08-29 02:52:09 +01:00
parent 5ab9ad2561
commit d19c437da9
No known key found for this signature in database
GPG key ID: 730750D54B7A9F66

View file

@ -2762,7 +2762,11 @@ struct Nullable(T)
{ {
private union DontCallDestructorT private union DontCallDestructorT
{ {
import std.traits : hasIndirections;
static if (hasIndirections!T)
T payload; T payload;
else
T payload = void;
} }
private DontCallDestructorT _value = DontCallDestructorT.init; private DontCallDestructorT _value = DontCallDestructorT.init;
@ -3020,7 +3024,7 @@ struct Nullable(T)
if (_isNull) if (_isNull)
{ {
// trusted since payload is known to be T.init here. // trusted since payload is known to be uninitialized.
() @trusted { moveEmplace(copy.payload, _value.payload); }(); () @trusted { moveEmplace(copy.payload, _value.payload); }();
} }
else else