proposal for general dup function

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Dec 10 11:47:02 PST 2012


On 12/10/12 2:07 PM, Dan wrote:
> On Monday, 10 December 2012 at 18:55:09 UTC, Jacob Carlborg wrote:
>
>> I'm pretty sure it can't be done. For classes one need to bypass the
>> constructor. The constructor is the only place where you can
>> initialize const/immutable fields. For class instance one would need
>> to cast it to a ubyte pointer (or similar) and then set the
>> const/immutable fields that way.
>>
>> I think it can be done safely, but not something the compiler can
>> guarantee.
>
> Only talking about structs here. classes were listed under issues not
> covered.
>
> Thanks
> Dan

There will be the same problems with structs containing pointers.

Andrei


More information about the Digitalmars-d mailing list