Discussion: Rvalue refs and a Move construtor for D

Les De Ridder les at lesderid.net
Thu Aug 29 07:31:58 UTC 2019


On Wednesday, 28 August 2019 at 23:32:01 UTC, Suleyman wrote:
> [...]
>
> Recently D adpoted the copy constructor, the postblit is 
> deprecated, and
> the postmove (DIP 1014) is also deprecated since it has the same
> problems as the postblit.

Please don't forget to explicitly deprecate DIP 1014 in your DIP 
if you
end up writing one, because it is not formally deprecated yet.

> [...]
>
> 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.

Some major reasons: C++ interop, perfect forwarding, movable but
non-copyable types (e.g. C++'s `std::unique_ptr`), cheaper 
reference
counting.

This is a good summary on rvalue references in C++:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2027.html


More information about the Digitalmars-d mailing list