What am I missing? Pure constructor behaves differently when assigning string member

jostly via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Nov 29 04:23:36 PST 2014


On Saturday, 29 November 2014 at 09:41:00 UTC, jostly wrote:
> I can't find a way to use a pure constructor to create both 
> mutable and immutable instances of the same class, when one of 
> the fields I assign is a string.

After poking around a bit, I believe it is caused by issue #10012 
https://issues.dlang.org/show_bug.cgi?id=10012 :

"This is current dmd implementation limitation. In complex cases 
dmd cannot detect that the constructor generates unique object."

So my question then becomes, how can I generate an unique object 
from the string? I tried using .idup on the incoming string, but 
that didn't help. Or is it simply still a problem of _detecting_ 
it for the compiler?


More information about the Digitalmars-d-learn mailing list