Warning on self assignment

Jonathan M Davis newsgroup.d at jmdavisprog.com
Wed Apr 25 07:23:24 UTC 2018


On Wednesday, April 25, 2018 03:32:09 Meta via Digitalmars-d-learn wrote:
> On Wednesday, 25 April 2018 at 02:32:32 UTC, Per Nordlöw wrote:
> > On Wednesday, 25 April 2018 at 02:23:04 UTC, Mike Franklin
> >
> > wrote:
> >> Are people using self assignment of structs as a way of
> >> force-running the postblit?  Is there a valid use case for
> >> that?
> >>
> >> Mike
> >
> > If they are, there should be a better way of force-running the
> > postblit.
>
> You can call __postblit or __xpostblit (I think the latter is a
> postblit introduced via a mixin or template mixin).

I seriously question that it's ever a good idea to call either, but
__postblit is the actual postblit constructor declared in the struct, and
__xpostblit is the function that deals with calling the postblit constructor
on all of the member variables and then calling __postblit.

- Jonathan M Davis




More information about the Digitalmars-d-learn mailing list