Discussion: Rvalue refs and a Move construtor for D

kinke kinke at gmx.net
Wed Sep 4 09:20:05 UTC 2019


On Wednesday, 4 September 2019 at 00:33:06 UTC, Exil wrote:
> How would it work with multi-function passing though? With a 
> rvalue reference, you are effectively just passing around a 
> reference, until the contents of the value are moved. So you 
> can pass it through N functions and it won't ever to do a 
> move/copy.
>
> Would you effectively be relying on the compiler to optimize 
> out the un-necessary moves, or would they be unavoidable, as 
> they effectively are now?

Yes, by changing the ABI details to the C++ way in this regard, 
making move/forward intrinsics and detecting them in argument 
expressions. Laid out earlier in this thread in 
https://forum.dlang.org/post/jogsaeqxouxaeflmgzcc@forum.dlang.org. We don't need rvalue refs in the language for that at all, just use a value parameter - rvalue args will be passed by ref under the hood, just like explicitly moved lvalue args.


More information about the Digitalmars-d mailing list