structs, ~this(), this(this) and reference counting

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Feb 18 08:25:16 PST 2012


On 2/18/12 7:59 AM, Michel Fortin wrote:
> It'd be nice though if the default assignment operator for structs would
> be generated like this:
>
> if (&other != &this)
> {
> ~this(); // destruct
> memcpy(&this, &other, other.sizeof); // blit
> this(this); // postblit
> }
>
> because this is the correct thing to do on assignment 99% of the time.
> So you'd have less boilerplate code to write.

Heh, we discussed this years ago but it was forgotten.

Andrei


More information about the Digitalmars-d mailing list