Discussion: Rvalue refs and a Move construtor for D

kinke noone at nowhere.com
Thu Sep 5 19:08:48 UTC 2019


On Thursday, 5 September 2019 at 18:59:50 UTC, kinke 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.

Maybe I should put more emphasis on the advantage: saving an 
allocation of a temporary and move-constructing it. That's 
peanuts for Suleyman's struct, but if we are talking about a 1KB 
struct or static array, then the savings may have a significant 
impact.
Additionally, the extra logic in the move ctor can be elided. DIP 
1014 (opPostMove) was born, IIRC, because Weka needs to keep 
track of the addresses of live instances in some outer code, so 
saving such re-registering may boost performance as well.


More information about the Digitalmars-d mailing list