Transitive R-Value Inference and Move Construction a la Rust

ag0aep6g via Digitalmars-d digitalmars-d at puremagic.com
Mon Sep 26 11:36:57 PDT 2016


On 09/26/2016 07:15 PM, Nordlöw wrote:
> On Monday, 26 September 2016 at 16:28:18 UTC, ag0aep6g wrote:
>> Inside `top`, `a` is an lvalue. It wouldn't be correct to move `a`
>> just because it originated from an rvalue.
>
> AFAICT, `top` can be moved in the call to `sub` if it's not used not
> returned below the call, right?

(I'm assuming `top` is a typo and you meant `a`.)

I don't know. To the layman that I am, it looks similar to tail call 
elimination. When the last use of `a` is in a call, it seems plausible 
that it could be possible to skip the postblit and the destructor, and 
let the called function take care of it. But it's probably not as simple 
as that.


More information about the Digitalmars-d mailing list