July 16, 2013 Re: immutable struct/class is mutable! | ||||
---|---|---|---|---|
| ||||
Posted in reply to JS | 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 |
July 16, 2013 Re: immutable struct/class is mutable! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | 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.
|
Copyright © 1999-2021 by the D Language Foundation