Discussion: Rvalue refs and a Move construtor for D

Per Nordlöw per.nordlow at gmail.com
Thu Aug 29 20:43:31 UTC 2019


On Wednesday, 28 August 2019 at 23:32:01 UTC, Suleyman wrote:
> Give me your thoughts on which way you prefer. And most 
> importantly I want you to convince me why adding rvalue refs is 
> good for D because there aren't many use cases that I know of.

Strongly related is my wish to make code like

struct Range(S)
{
     this(S s) {
         this.s = s; // currently passed by copy, but should be 
passed by move
     }
     S s;
}

perform pass by move instead of pass by copy thereby enable S to 
be a non-copyable value-type C++-style container via

     @disable this(this);

This will enable range-based algorithms in Phobos to take r-value 
references to non-copyable containers and generators as 
arguments. This will increase performance because the containers 
currently needs to be wrapped in a reference-counting storage 
such as std.typecons.RefCounted.


More information about the Digitalmars-d mailing list