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

Functions 18

fnsize_t goodAllocSize(A)(auto ref A a, size_t n)The default good size allocation is deduced as `n` rounded up to the allocator's alignment.
fnsize_t roundUpToMultipleOf(size_t s, uint base) @safe @nogc nothrow pure
fnsize_t roundUpToAlignment(size_t n, uint alignment) @safe @nogc nothrow pure
fnsize_t roundDownToAlignment(size_t n, uint alignment) @safe @nogc nothrow pure
fnvoid[] roundUpToAlignment(void[] b, uint a) @nogc nothrow pure
fnsize_t divideRoundUp(size_t a, size_t b) @safe @nogc nothrow pure
fnvoid[] roundStartToMultipleOf(void[] s, uint base) @nogc nothrow pure
fnsize_t roundUpToPowerOf2(size_t s) @safe @nogc nothrow pure
fnuint trailingZeros(ulong x) @safe @nogc nothrow pure
fnbool alignedAt(T)(T * ptr, uint alignment) @nogc nothrow pure
fnsize_t effectiveAlignment(void * ptr) @nogc nothrow pure
fnvoid * alignDownTo(return scope void * ptr, uint alignment) @nogc nothrow pure
fnvoid * alignUpTo(return scope void * ptr, uint alignment) @nogc nothrow pure
fnbool isGoodStaticAlignment(uint x) @safe @nogc nothrow pure
fnbool isGoodDynamicAlignment(uint x) @safe @nogc nothrow pure
fnbool reallocate(Allocator)(ref Allocator a, ref void[] b, size_t s)The default `reallocate` function first attempts to use `expand`. If Allocator.expand is not defined or returns `false`, `reallocate` allocates a new block of memory of appropriate size and copies ...
fnbool alignedReallocate(Allocator)(ref Allocator alloc, ref void[] b, size_t s, uint a) if (hasMember!(Allocator, "alignedAllocate"))The default `alignedReallocate` function first attempts to use `expand`. If `Allocator.expand` is not defined or returns `false`, alignedReallocate allocates a new block of memory of appropriate s...
fnstring forwardToMember(string member, string[] funs...)Forwards each of the methods in `funs` (if defined) to `member`.

Variables 3

enumvarchooseAtRuntime = size_t.max - 1

chooseAtRuntime is 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.

enumvarunbounded = size_t.max

unbounded is 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. If unbounded is passed for maxNodes, then there is no limit and no checking for the number of nodes.

enumvarplatformAlignment = std.algorithm.comparison.max(double.alignof, real.alignof)

The alignment that is guaranteed to accommodate any D object allocation on the current platform.

Templates 2

tmplstateSize(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.

tmplhasStaticallyKnownAlignment(Allocator)

Returns true if the Allocator has the alignment known at compile time; otherwise it returns false.