Shallow copy object when type is know

Alex Parrill via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Apr 20 11:48:58 PDT 2016


On Wednesday, 20 April 2016 at 12:32:48 UTC, Tofu Ninja wrote:
> Is there a way to shallow copy an object when the type is 
> known? I cant seem to figure out if there is a standard way. I 
> can't just implement a copy function for the class, I need a 
> generic solution.

A generic class copy function would require accessing private 
fields, so a clean per-attribute class copy is impossible. Doing 
a bitwise copy might work except for the synchronization mutex 
pointer.

Can you elaborate on why you need this?


More information about the Digitalmars-d-learn mailing list