英語版
このページの英語版を見る

std.experimental.allocator.building_blocks.scoped_allocator

struct ScopedAllocator(ParentAllocator);
ScopedAllocatorはすべての割り当て要求をParentAllocator に委任する。 破棄されると ScopedAllocatorオブジェクトが破棄されると、自動的にdeallocate を呼び出す。(deallocateAll 関数も同じセマンティクスで実装されている)。
deallocate もサポートされている。 のオーバーヘッドが発生する。 ScopedAllocatorもサポートされている。deallocateAllocatorListRegion を組み合わせたよりシンプルな設計を推奨する。
Examples:
import std.experimental.allocator.mallocator : Mallocator;
import std.typecons : Ternary;
ScopedAllocator!Mallocator alloc;
writeln(alloc.empty); // Ternary.yes
const b = alloc.allocate(10);
writeln(b.length); // 10
writeln(alloc.empty); // Ternary.no
Allocator parent;
ParentAllocator がステートフルな場合、 parentへのアクセスを与えるプロパティである。 AffixAllocator!ParentAllocator へのアクセスを与えるプロパティである、 parentAffixAllocator!ParentAllocator.instance のエイリアスである。
enum auto alignment;
アライメント
size_t goodAllocSize(size_t n);
に転送する。 parent.goodAllocSize(これは に転送する(これは管理オーバーヘッドを考慮する)。
void[] allocate(size_t n);
メモリを確保する。管理のために、実際には親から余分なメモリを確保する。 を確保する。
bool expand(ref void[] b, size_t delta);
parent.expand(b, delta) に転送する。
bool reallocate(ref void[] b, size_t s);
新しいサイズに再割り当てする。 bを新しいサイズに再割り当てする。 s.
Ternary owns(void[] b);
に転送する。 parent.owns(b).
bool deallocate(void[] b);
デアロケートする b.
bool deallocateAll();
割り当てられたすべてのメモリを解放する。
const pure nothrow @nogc @safe Ternary empty();
このアロケータがどのメモリにも責任を負わない場合はTernary.yes を返す、 Ternary.no を返す。(決してTernary.unknown を返さない)。