Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
std.experimental.allocator.building_blocks.scoped_allocator
- ScopedAllocator delegates all allocation requests to ParentAllocator. When destroyed, the ScopedAllocator object automatically calls deallocate for all memory allocated through its lifetime. (The deallocateAll function is also implemented with the same semantics.)deallocate is also supported, which is where most implementation effort and overhead of ScopedAllocator go. If deallocate is not needed, a simpler design combining AllocatorList with Region is recommended.Examples:
import std.experimental.allocator.mallocator : Mallocator; ScopedAllocator!Mallocator alloc; assert(alloc.empty == Ternary.yes); const b = alloc.allocate(10); assert(b.length == 10); assert(alloc.empty == Ternary.no);
- Alignment offered
- Allocates memory. For management it actually allocates extra memory from the parent.
- Reallocates b to new size s.
- Deallocates b.
- Deallocates all memory allocated.
- Returns Ternary.yes if this allocator is not responsible for any memory, Ternary.no otherwise. (Never returns Ternary.unknown.)
Copyright © 1999-2017 by Digital Mars ®, All Rights Reserved | Page generated by
Ddoc on (no date time)