Discussion: Rvalue refs and a Move construtor for D

Manu turkeyman at gmail.com
Thu Sep 5 21:21:05 UTC 2019

On Thu, Sep 5, 2019 at 12:00 PM kinke via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> On Thursday, 5 September 2019 at 18:46:59 UTC, Exil wrote:
> > There's still similar to the problem we have now. You're still
> > doing a memcpy() each time with S.init.
> Resetting the moved-from instance to T.init or something similar
> is what you'd do in the move ctor anyway (besides blitting the
> previous contents into the new instance and maybe doing some more
> adjustments), and definitely what the default implementation of
> the move ctor would do.

I agree the default might do that, but it's equally valid to do
nothing (if destruction has no side-effects), or do swap() if you want
to allow the naturally occurring destructor to tidy up, or various
other strategies.
If we want to allow these potentially efficient implementations, then
perhaps we should mark moved lvalues with a bit saying they have been
invalidated, and the compiler can complain about future references?

More information about the Digitalmars-d mailing list