Discussion: Rvalue refs and a Move construtor for D

kinke noone at nowhere.com
Thu Sep 5 18:59:50 UTC 2019


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.

> And you are calling the destructor now too, which entirely 
> depends on what it is.

As stated above, there's no extra destruction - the first one is 
for the by-value parameter (which would otherwise be the 
moved-from temporary), and the second is the regular destruction 
of the moved-from lvalue.


More information about the Digitalmars-d mailing list