UniquePtr in D

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


When working with C-libraries in D I often wish for a equivalent of the 
C++11 unique_ptr. Unfortunately this is not possible in D. Consider the 
following source code:

http://dpaste.dzfl.pl/6e71c815

Is error 1 a bug? Because there should cleary not be any copy at this point.

Should we implement moving of u so that error 2 goes away? The compiler 
could move u into the function and move back out afterwards, but that 
would mean that the contents of u would be invalid for the duration of 
the function call (unsafe?)

Kind Regards
Benjamin Thaut


More information about the Digitalmars-d mailing list