Uniq

A helper struct that manage the lifetime of a Disposable using RAII. Note: dlang has capability to enforce a parameter be a lvalue (ref param) but has no mechanism such as c++ rvalue reference which would enforce true uniqueness by the compiler. Uniq gives additional robustness, but it is up to the programmer to make sure that the values passed in by rvalue are not referenced somewhere else in the code

Constructors

this
this(T obj)

Constructor taking rvalue. Uniqueness is achieve only if there is no aliases of the passed reference.

this
this(T obj)

Constructor taking lvalue. Uniqueness is achieve only if there is no other copies of the passed reference.

this
this(Uniq!U u)

Constructor that take a rvalue. u can only be a rvalue because postblit is disabled.

Destructor

~this
~this()

Destructor that disposes the resource.

Postblit

this(this)
this(this)
Undocumented in source.

Alias This

obj

Forwarding method calls and member access to the underlying object.

Members

Aliases

Resource
alias Resource = T
Undocumented in source.

Functions

assigned
bool assigned()

Checks whether a resource is assigned.

dispose
void dispose()

Explicitely ispose the underlying resource.

opAssign
void opAssign(Uniq!U u)

Transfer ownership from a Uniq of a type that is convertible to our type. u can only be a rvalue because postblit is disabled.

opCast
bool opCast()

Shortcut to assigned

release
Uniq release()

Transfer the ownership.

Properties

obj
inout(T) obj [@property getter]

A view on the underlying object.

Meta