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

Shachar Shemesh via Digitalmars-d digitalmars-d at puremagic.com
Mon Feb 1 05:21:02 PST 2016


Hi all,

I have a non-copyable struct with move semantics. In other words, a 
struct with @disable this(this), but with working overloads for the 
this(copy) and opAssign.

Now I have an instance of that struct. I would like to be able to 
voluntarily give up ownership for the sake of another instance.

In C++, I would do something like this:

unique_ptr<int> p (new int), q;

q = std::move(p);

I am unsure what is the correct way to do this under D.

Shachar


More information about the Digitalmars-d mailing list