Struct Ref
Reference counting support.
struct Ref(T)
if (is(T : RefCountedObject));
Implemented for case when T
is RefCountedObject
.
Similar to shared_ptr in C++.
Allows to share object, destroying it when no more references left.
Useful for automatic destroy of objects.
Constructors
Name | Description |
this
(data)
|
Init from T
|
Fields
Type | Name | Description |
T
|
_data
|
|
Properties
Type | Name | Description |
T
|
get [get]
|
Returns object reference (null if not assigned)
|
const(T)
|
get [get]
|
Returns const reference from const object
|
bool
|
isNull [get]
|
Returns true if object is not assigned
|
size_t
|
refCount [get]
|
Returns counter of references
|
Methods
Name | Description |
addRef
()
|
Increment reference counter
|
clear
()
|
Clear reference
|
opAssign
(data)
|
Assign from another refcount by reference
|
opAssign
(data)
|
Assign from another refcount by value
|
opAssign
(data)
|
Assign object
|
releaseRef
()
|
Decrement reference counter, destroy object if no more references left
|