The OpenD Programming Language

fallbackAllocator

Convenience function that uses type deduction to return the appropriate FallbackAllocator instance. To initialize with allocators that don't have state, use their it static member.

FallbackAllocator!(Primary, Fallback)
fallbackAllocator
(
Primary
Fallback
)
(
auto ref Primary p
,
auto ref Fallback f
)

Examples

import std.experimental.allocator.building_blocks.region : Region;
import std.experimental.allocator.gc_allocator : GCAllocator;
import std.typecons : Ternary;
auto a = fallbackAllocator(Region!GCAllocator(1024), GCAllocator.instance);
auto b1 = a.allocate(1020);
assert(b1.length == 1020);
assert(a.primary.owns(b1) == Ternary.yes);
auto b2 = a.allocate(10);
assert(b2.length == 10);
assert(a.primary.owns(b2) == Ternary.no);

Meta