RefCounted

A struct to ensure only one copy of the provided item exists.

This differs from Phobos' std.typecons.RefCounted by using the GC to store the memory, instead of C's heap. The benefit here is that this version of RefCounted can be @safe.

The block containing the item is pinned in the GC until all references are gone, which means the destructor will be run synchronously when the last reference is removed. Therefore, it is safe to store a RefCounted struct inside a GC allocated type.

Constructors

this
this(Args args)

Constructor. the underlying T is constructed using the parameters.

Destructor

~this
~this()
Undocumented in source.

Postblit

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

Alias This

_get

Alias the item to this struct.

Members

Functions

_get
T _get()

Get a reference to the item. Note that if you store a reference to this item, it is possible the item will in the future be destroyed, but the memory will still be present (until the GC cleans it up).

opAssign
void opAssign(RefCounted other)

Assignment to another ref counted item.

opAssign
void opAssign(T other)

Assignment to another T.

Meta