UniquePtr in D

Benjamin Thaut code at benjamin-thaut.de
Sun Dec 22 05:40:28 PST 2013


Am 22.12.2013 14:36, schrieb Sergei Nosov:
> 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.

Uh, this looks a lot better then std.typecons.Unique
Did you try doing a pull request to replace std.typecons.Unique with 
your implementation?

Kind Regards
Benjamin Thaut


More information about the Digitalmars-d mailing list