Takes ownership over value, setting the counter to 1. value may be a pointer, an object or a dynamic array.
Destroys the owned object.
$(D_PSYMBOL Unique) is noncopyable.
Initialized this Unique and takes ownership over rhs.
Dereferences the pointer. It is defined only for pointers, not for reference types like classes, that can be accessed directly.
Sets the internal pointer to $(D_KEYWORD). The allocator isn't changed.
Allocator.
This property checks if the allocator was set in the constructor and sets it to the default one, if not.
Value type.
auto p = defaultAllocator.make!int(5); auto s = Unique!int(p, defaultAllocator); assert(*s == 5);
static bool destroyed; static struct F { ~this() @nogc nothrow @safe { destroyed = true; } } { auto s = Unique!F(defaultAllocator.make!F(), defaultAllocator); } assert(destroyed);
$(D_PSYMBOL Unique) stores an object that gets destroyed at the end of its scope.