automem

C++-style automatic memory management smart pointers for D using stdx.allocator.

Unlike the C++ variants, the smart pointers themselves allocate the memory for the objects they contain. That ensures the right allocator is used to dispose of the memory as well.

Allocators are template arguments instead of using theAllocator so that these smart pointers can be used in @nogc code. However, they will default to typeof(theAllocator) for simplicity. The examples above will be explicit.

Another reason to have to pass in the type of allocator is to decide how it is to be stored. Stateless allocators can be "stored" by value and imply zero-cost Unique pointers. Singleton allocators such as Mallocator (that have an instance attribute/member function) don't need to be passed in to the constructor. This is detected at compile-time as an example of design by instrospection.

RefCounted leverages D's type system by doing atomic reference counting *iff* the type of the contained object is shared. Otherwise it's non-atomic.

Modules

allocator
module automem.allocator

Custom versions of stdx.allocator functions (unfortunately)

ref_counted
module automem.ref_counted

A reference-counted smart pointer.

test_utils
module automem.test_utils
Undocumented in source.
traits
module automem.traits
Undocumented in source.
unique
module automem.unique

A unique pointer.

unique_array
module automem.unique_array

RAII arrays

utils
module automem.utils
Undocumented in source.

Public Imports

automem.unique
public import automem.unique;
Undocumented in source.
automem.unique_array
public import automem.unique_array;
Undocumented in source.
automem.ref_counted
public import automem.ref_counted;
Undocumented in source.

Members

Mixins

__anonymous
mixin TestUtils
Undocumented in source.

Mixed In Members

From mixin TestUtils

theTestAllocator
auto theTestAllocator()

Returns an object that, while in scope, replaces whatever theAllocator was with TestAllocator.

before
void before()
Undocumented in source. Be warned that the author may not have intended to support it.
after
void after()
Undocumented in source. Be warned that the author may not have intended to support it.
reset
void reset()
Undocumented in source. Be warned that the author may not have intended to support it.
_writelnUt
void _writelnUt(T args)
Undocumented in source. Be warned that the author may not have intended to support it.

Meta