tanya.memory.smartref

Smart pointers.

A smart pointer is an object that wraps a raw pointer or a reference (class, dynamic array) to manage its lifetime.

This module provides two kinds of lifetime management strategies:

  • Reference counting
  • Unique ownership

Members

Functions

refCounted
RefCounted!T refCounted(Allocator allocator, A args)

Constructs a new object of type T and wraps it in a $(D_PSYMBOL RefCounted) using args as the parameter list for the constructor of T.

refCounted
RefCounted!T refCounted(Allocator allocator, size_t size)

Constructs a new array with size elements and wraps it in a $(D_PSYMBOL RefCounted).

unique
Unique!T unique(Allocator allocator, A args)

Constructs a new object of type T and wraps it in a $(D_PSYMBOL Unique) using args as the parameter list for the constructor of T.

unique
Unique!T unique(Allocator allocator, size_t size)

Constructs a new array with size elements and wraps it in a $(D_PSYMBOL Unique).

Structs

RefCounted
struct RefCounted(T)

Reference-counted object containing a T value as payload. $(D_PSYMBOL RefCounted) keeps track of all references of an object, and when the reference count goes down to zero, frees the underlying store.

Unique
struct Unique(T)

$(D_PSYMBOL Unique) stores an object that gets destroyed at the end of its scope.

Meta