mirror of
https://github.com/dlang/phobos.git
synced 2025-04-30 23:20:29 +03:00
std.typecons: make Nullable payload void initialized
Signed-off-by: Luís Ferreira <contact@lsferreira.net>
This commit is contained in:
parent
5ab9ad2561
commit
d19c437da9
1 changed files with 6 additions and 2 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue