UniquePtr in D

Sergei Nosov sergei.nosov at gmail.com
Sun Dec 22 05:36:40 PST 2013


On Sunday, 22 December 2013 at 13:28:05 UTC, Benjamin Thaut wrote:
> Well yes, but I'm more interrested in moving around the 
> ownership between functions, which works in c++11 because of 
> the move semantics they implemented. This doesn't work in D for 
> the shown reasons.

http://dpaste.dzfl.pl/d1a6f7d0

That's as close as I could get. It doesn't move the parameters 
outside of the function. I workaround it by returning the unique 
input arguments. It's like "here's your object back".

Everything is pretty much safe in @safe mode - as long as you 
don't pass Unique values by reference.


More information about the Digitalmars-d mailing list