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

rsw0x via Digitalmars-d digitalmars-d at puremagic.com
Sat Feb 13 12:11:45 PST 2016


On Saturday, 13 February 2016 at 19:25:37 UTC, Ola Fosheim 
Grøstad wrote:
>> I'm not sure what you mean by "has move semantics" here.  It 
>> does not have C++'s move semantics, no, but I would say D has 
>> its own move semantics.  It has a move() function that 
>> transfers raw state between objects, and D structs are 
>> supposed to be designed so they are movable by means of raw 
>> bit transfer, allowing the compiler and GC to move them around 
>> as it sees fit.  But maybe I'm missing something?
>
> Well, but that is like saying that C++03 also had move 
> semantics. There is nothing special about D's move(), it's just 
> a library function?

D "guarantees" NRVO which is what enables its move semantics, C++ 
did/does not.

Quotes because IIRC(?) it used to be part of the spec and it 
isn't anymore, I don't think Walter or Andrei have addressed this 
yet so I'm not sure if it's intended.


More information about the Digitalmars-d mailing list