How do you make a copy TO and object when you're INSIDE of it?

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 24 07:12:56 PDT 2015


On 7/24/15 4:47 AM, "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm at gmx.net>" 
wrote:
> Apart from what others have said, for a class `this` is the _reference_
> to the current object, i.e. a "pointer". If the compiler allowed
> assigning to it, it would not modify the contents of your object.
>
> If you want to assign all of the elements at once, you can use `tupleof`
> (untested):
>
>      this.tupleof = other.tupleof;

I'm quite certain this wouldn't copy the derived data. So be careful 
when doing this, you can only do this on final classes.

-Steve


More information about the Digitalmars-d-learn mailing list