mirror of
https://github.com/dlang/phobos.git
synced 2025-05-06 11:07:39 +03:00
Merge pull request #8378 from ibuclaw/merge_stable
Merge branch 'stable' into merge_stable Signed-off-by: Nicholas Wilson <thewilsonator@users.noreply.github.com> Merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
This commit is contained in:
commit
2629671c15
1 changed files with 34 additions and 8 deletions
|
@ -2798,13 +2798,24 @@ struct Nullable(T)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this (ref return scope inout Nullable!T rhs) inout
|
static if (__traits(hasPostblit, T))
|
||||||
{
|
{
|
||||||
_isNull = rhs._isNull;
|
this(this)
|
||||||
if (!_isNull)
|
{
|
||||||
_value.payload = rhs._value.payload;
|
if (!_isNull)
|
||||||
else
|
_value.payload.__xpostblit();
|
||||||
_value = DontCallDestructorT.init;
|
}
|
||||||
|
}
|
||||||
|
else static if (__traits(hasCopyConstructor, T))
|
||||||
|
{
|
||||||
|
this(ref return scope inout Nullable!T rhs) inout
|
||||||
|
{
|
||||||
|
_isNull = rhs._isNull;
|
||||||
|
if (!_isNull)
|
||||||
|
_value.payload = rhs._value.payload;
|
||||||
|
else
|
||||||
|
_value = DontCallDestructorT.init;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9630,13 +9641,28 @@ unittest
|
||||||
{
|
{
|
||||||
int b;
|
int b;
|
||||||
@disable this(this);
|
@disable this(this);
|
||||||
this (ref return scope inout S rhs) inout
|
this(ref return scope inout S rhs) inout
|
||||||
{
|
{
|
||||||
this.b = rhs.b + 1;
|
this.b = rhs.b + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Nullable!S s1 = S(1);
|
Nullable!S s1 = S(1);
|
||||||
|
assert(s1.get().b == 2);
|
||||||
Nullable!S s2 = s1;
|
Nullable!S s2 = s1;
|
||||||
assert(s2.get().b > s1.get().b);
|
assert(s2.get().b == 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@safe unittest
|
||||||
|
{
|
||||||
|
static struct S
|
||||||
|
{
|
||||||
|
int b;
|
||||||
|
this(this) { ++b; }
|
||||||
|
}
|
||||||
|
|
||||||
|
Nullable!S s1 = S(1);
|
||||||
|
assert(s1.get().b == 2);
|
||||||
|
Nullable!S s2 = s1;
|
||||||
|
assert(s2.get().b == 3);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue