D's equivalent to C++'s std::move?

Ola Fosheim Grøstad via Digitalmars-d digitalmars-d at puremagic.com
Sat Feb 13 13:01:00 PST 2016


On Saturday, 13 February 2016 at 20:39:22 UTC, rsw0x wrote:
> It's not move semantics, it enables move semantics.
> Yes, C++ compilers do it(Walter 'invented' it, fyi) but C++ 
> doesn't guarantee it. D (is supposed) to) guarantee it, which 
> enables move semantics.

I understand what you mean. You mean construction of read/write 
protected objects, which you can override with dedicated 
functions with special privileges. But you can do that in old C++ 
as well... You only need to create your own reference type.

Of course, there is not much to invent as the common C paradigm 
for objects has always been that kind of initialization which RVO 
"emulates":

   data_t data; initialize_data(&data);

The primary difference is that C does not provide any protection 
for the data. The issue in C++ is that it is not an optimization, 
as it breaks the language semantics (which the standard now 
allows).



More information about the Digitalmars-d mailing list