mirror of
https://github.com/dlang/phobos.git
synced 2025-05-12 23:29:01 +03:00
std.experimental.checkedint should support chain assignment.
Cf. bug #21169.
This commit is contained in:
parent
f97c2c05be
commit
34a14509d2
1 changed files with 11 additions and 1 deletions
|
@ -351,12 +351,14 @@ if (isIntegral!T || is(T == Checked!(U, H), U, H))
|
|||
/**
|
||||
Assignment operator. Has the same constraints as the constructor.
|
||||
*/
|
||||
void opAssign(U)(U rhs) if (is(typeof(Checked!(T, Hook)(rhs))))
|
||||
ref Checked opAssign(U)(U rhs) return
|
||||
if (is(typeof(Checked!(T, Hook)(rhs))))
|
||||
{
|
||||
static if (isIntegral!U)
|
||||
payload = rhs;
|
||||
else
|
||||
payload = rhs.payload;
|
||||
return this;
|
||||
}
|
||||
///
|
||||
@system unittest
|
||||
|
@ -368,6 +370,14 @@ if (isIntegral!T || is(T == Checked!(U, H), U, H))
|
|||
assert(a == 4242);
|
||||
}
|
||||
|
||||
///
|
||||
@system unittest
|
||||
{
|
||||
Checked!long a, b;
|
||||
a = b = 3;
|
||||
assert(a == 3 && b == 3);
|
||||
}
|
||||
|
||||
// opCast
|
||||
/**
|
||||
Casting operator to integral, `bool`, or floating point type. If `Hook`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue