Truly algebraic Variant and Nullable
ag0aep6g
anonymous at example.com
Tue Dec 22 17:20:03 UTC 2020
On Tuesday, 22 December 2020 at 16:53:11 UTC, jmh530 wrote:
> For
> v = cast(size_t) x;
> I thought @safe prevented explicitly casting an immutable to a
> mutable, but the code below seems to suggest it is ok in this
> case...
>
> void main() @safe
> {
> immutable x = 32;
> auto v = cast(size_t) x;
> }
It's ok because you're making a copy. Casting from immutable to
mutable is only dangerous when altering the mutable thing would
affect the immutable thing, as it happens with pointers and such.
More information about the Digitalmars-d-announce
mailing list