immutable struct/class is mutable!
JS
js.mdnq at gmail.com
Mon Jul 15 20:48:19 PDT 2013
On Tuesday, 16 July 2013 at 02:59:50 UTC, Ali Çehreli wrote:
> On 07/15/2013 07:50 AM, JS wrote:
>
> > Why does isMutable and isAssignable return true for a
> struct/class that
> > are immutable?
> >
> > immutable struct A { }
> >
> > isMutable!A returns true.
>
> import std.traits;
>
> struct S
> {}
>
> alias ImmutableS = immutable(S);
>
> void main()
> {
> static assert(!isMutable!ImmutableS);
> static assert(!isAssignable!ImmutableS);
> }
>
> Is that what you are looking for?
>
> Ali
This would essentially work but I really would prefer a short
hand notation immutable(struct) S. I am nesting structs and
would have a lot of aliases.
More information about the Digitalmars-d-learn
mailing list