Discussion: Rvalue refs and a Move construtor for D

Suleyman sahmi.soulaimane at gmail.com
Thu Sep 5 22:51:59 UTC 2019


On Thursday, 5 September 2019 at 22:31:41 UTC, Manu wrote:
> If you lose the `@rvalue` attribute, you have no idea that you 
> can
> steal the contents of `value`... it's not a move argument, it's 
> just
> an lvalue argument by ref.
> Inside that function, you must copy, because you can't know 
> what you received.

+1

I didn't realize this until I pondered on Exil's argument. Then I 
realized why the "-preview=..." feature doesn't cover this case. 
Essentially `ref` doesn't preserve move information i.e. it 
doesn't tell you whether the source was an lvalue or an rvalue 
converted to a temporary. Hence you can't just move or `forward` 
at the bottom of the chain.



More information about the Digitalmars-d mailing list