initializing const maps with value types having aliasing

bearophile bearophileHUGS at lycos.com
Wed Mar 20 12:11:09 PDT 2013


Dan:

>   this(this) { x = x.dup; }

I think this(this) doesn't work well with const.


>   cast(S[string])m = [ "foo" : S(['a']) ];

I think I have never seen code like that. What's the meaning? :-)


(Also if you remove that cast then dmd gives bad error messages 
with no line numbers:

Error: mutable method temp.S.__postblit is not callable using a 
const object
Error: cannot modify struct this Slot with immutable members

).

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list