mirror of
https://github.com/dlang/phobos.git
synced 2025-05-13 15:52:41 +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.
|
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)
|
static if (isIntegral!U)
|
||||||
payload = rhs;
|
payload = rhs;
|
||||||
else
|
else
|
||||||
payload = rhs.payload;
|
payload = rhs.payload;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
@system unittest
|
@system unittest
|
||||||
|
@ -368,6 +370,14 @@ if (isIntegral!T || is(T == Checked!(U, H), U, H))
|
||||||
assert(a == 4242);
|
assert(a == 4242);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
@system unittest
|
||||||
|
{
|
||||||
|
Checked!long a, b;
|
||||||
|
a = b = 3;
|
||||||
|
assert(a == 3 && b == 3);
|
||||||
|
}
|
||||||
|
|
||||||
// opCast
|
// opCast
|
||||||
/**
|
/**
|
||||||
Casting operator to integral, `bool`, or floating point type. If `Hook`
|
Casting operator to integral, `bool`, or floating point type. If `Hook`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue