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.common
Utility and ancillary artifacts of std.experimental.allocator. This module
shouldn't be used directly; its functionality will be migrated into more
appropriate parts of std.
Authors:
Andrei Alexandrescu, Timon Gehr (Ternary)
- template
stateSize(T) - Returns the size in bytes of the state that needs to be allocated to hold an object of type T.
stateSize!T is zero for structs that are not nested and have no nonstatic member variables. - enum auto
hasStaticallyKnownAlignment(Allocator); - Returns true if the Allocator has the alignment known at compile time; otherwise it returns false.
- enum ulong
chooseAtRuntime; chooseAtRuntimeis a compile-time constant of type size_t that several parameterized structures in this module recognize to mean deferral to runtime of the exact value. For example, BitmappedBlock!(Allocator, 4096) (described in detail below) defines a block allocator with block size of 4096 bytes, whereas BitmappedBlock!(Allocator,chooseAtRuntime) defines a block allocator that has a field storing the block size, initialized by the user.- enum ulong
unbounded; unboundedis a compile-time constant of type size_t that several parameterized structures in this module recognize to mean "infinite" bounds for the parameter. For example, Freelist (described in detail below) accepts a maxNodes parameter limiting the number of freelist items. Ifunboundedis passed for maxNodes, then there is no limit and no checking for the number of nodes.- enum uint
platformAlignment; - The alignment that is guaranteed to accommodate any D object allocation on the current platform.
- size_t
goodAllocSize(A)(auto ref Aa, size_tn); - The default good size allocation is deduced as
nrounded up to the allocator's alignment. - package pure nothrow @nogc @safe size_t
roundUpToMultipleOf(size_ts, uintbase); - Returns
srounded up to a multiple ofbase. - package pure nothrow @nogc @safe size_t
roundUpToAlignment(size_tn, uintalignment); - Returns
nrounded up to a multiple ofalignment, which must be a power of 2. - package pure nothrow @nogc @safe size_t
roundDownToAlignment(size_tn, uintalignment); - Returns
nrounded down to a multiple ofalignment, which must be a power of 2. - package pure nothrow @nogc void[]
roundUpToAlignment(void[]b, uinta); - Advances the beginning of
bto start at alignmenta. The resulting buffer may therefore be shorter. Returns the adjusted buffer, ornullif obtaininganon-empty buffer is impossible. - package pure nothrow @nogc @safe size_t
divideRoundUp(size_ta, size_tb); - Like
a/bbut rounds the result up, not down. - package pure nothrow @nogc void[]
roundStartToMultipleOf(void[]s, uintbase); - Returns
srounded up to a multiple ofbase. - package pure nothrow @nogc @safe size_t
roundUpToPowerOf2(size_ts); - Returns
srounded up to the nearest power of 2. - package pure nothrow @nogc @safe uint
trailingZeros(ulongx); - Returns the number of trailing zeros of
x. - pure nothrow @nogc bool
alignedAt(T)(T*ptr, uintalignment); - Returns true if
ptris aligned atalignment. - package pure nothrow @nogc uint
effectiveAlignment(void*ptr); - Returns the effective alignment of
ptr, i.e. the largest power of two that is a divisor ofptr. - package pure nothrow @nogc void*
alignDownTo(void*ptr, uintalignment); - Aligns a pointer down to a specified
alignment. The resulting pointer is less than or equal to the given pointer. - package pure nothrow @nogc void*
alignUpTo(void*ptr, uintalignment); - Aligns a pointer up to a specified
alignment. The resulting pointer is greater than or equal to the given pointer. - bool
reallocate(Allocator)(ref Allocatora, ref void[]b, size_ts); - The default
reallocatefunction first attempts to use expand. If Allocator.expand is not defined or returnsfalse,reallocateallocatesanew block of memory of appropriate size and copies data from the old block to the new block. Finally, if Allocator defines deallocate,reallocateuses it to free the old memory block.reallocatedoes not attempt to use Allocator.reallocateeven if defined. This is deliberate so allocators may use it internally within their own implementation ofreallocate. - bool
alignedReallocate(Allocator)(ref Allocatoralloc, ref void[]b, size_ts, uinta); - The default
alignedReallocatefunction first attempts to use expand. If Allocator.expand is not defined or returnsfalse,alignedReallocateallocatesanew block of memory of appropriate size and copies data from the old block to the new block. Finally, if Allocator defines deallocate,alignedReallocateuses it to free the old memory block.alignedReallocatedoes not attempt to use Allocator.reallocate even if defined. This is deliberate so allocators may use it internally within their own implementation of reallocate. - string
forwardToMember(stringmember, string[]funs...); - Forwards each of the methods in
funs(if defined) tomember.
Copyright © 1999-2017 by the D Language Foundation | Page generated by
Ddoc on (no date time)