stdx.allocator.common
Utility and ancillary artifacts of stdx.allocator. This module
shouldn't be used directly; its functionality will be migrated into more
appropriate parts of std.
-
Declaration
templatestateSize(T)Returns the size in bytes of the state that needs to be allocated to hold an object of type . is zero for s that are not nested and have no nonstatic member variables.
-
Declaration
enum autohasStaticallyKnownAlignment(Allocator);Returns
trueif theAllocatorhas the alignment known at compile time; otherwise it returnsfalse. -
Declaration
enum ulongchooseAtRuntime;is a compile-time constant of type that several parameterized structures in this module recognize to mean deferral to runtime of the exact value. For example, (described in detail below) defines a block allocator with block size of 4096 bytes, whereas defines a block allocator that has a field storing the block size, initialized by the user.
-
Declaration
enum ulongunbounded;is a compile-time constant of type that several parameterized structures in this module recognize to mean "infinite" bounds for the parameter. For example, (described in detail below) accepts a parameter limiting the number of freelist items. If is passed for , then there is no limit and no checking for the number of nodes.
-
Declaration
enum uintplatformAlignment;The alignment that is guaranteed to accommodate any D object allocation on the current platform.
-
Declaration
size_tgoodAllocSize(A)(auto ref Aa, size_tn);The default good size allocation is deduced as rounded up to the allocator's alignment.
-
Declaration
package pure nothrow @nogc @safe size_troundUpToMultipleOf(size_ts, uintbase);Returns
srounded up to a multiple ofbase. -
Declaration
package pure nothrow @nogc @safe size_troundUpToAlignment(size_tn, uintalignment);Returns
rounded up to a multiple ofnalignment, which must be a power of 2. -
Declaration
package pure nothrow @nogc @safe size_troundDownToAlignment(size_tn, uintalignment);Returns
rounded down to a multiple ofnalignment, which must be a power of 2. -
Declaration
package pure nothrow @nogc void[]roundUpToAlignment(void[]b, uinta);Advances the beginning of
to start at alignmentb. The resulting buffer may therefore be shorter. Returns the adjusted buffer, oranullif obtaininganon-empty buffer is impossible. -
Declaration
package pure nothrow @nogc @safe size_tdivideRoundUp(size_ta, size_tb);Like
but rounds the result up, not down.a/b -
Declaration
package pure nothrow @nogc void[]roundStartToMultipleOf(void[]s, uintbase);Returns
rounded up to a multiple ofs.base -
Declaration
package pure nothrow @nogc @safe size_troundUpToPowerOf2(size_ts);Returns rounded up to the nearest power of 2.
-
Declaration
package pure nothrow @nogc @safe uinttrailingZeros(ulongx);Returns the number of trailing zeros of .
-
Declaration
pure nothrow @nogc boolalignedAt(T)(T*ptr, uintalignment);Returns
trueifis aligned atptr.alignment -
Declaration
package pure nothrow @nogc uinteffectiveAlignment(void*ptr);Returns the effective alignment of
, i.e. the largest power of two that is a divisor ofptr.ptr -
Declaration
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. -
Declaration
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. -
Declaration
boolreallocate(Allocator)(ref Allocatora, ref void[]b, size_ts);The default function first attempts to use . If is not defined or returns , allocates
anew block of memory of appropriate size and copies data from the old block to the new block. Finally, if defines , uses it to free the old memory block.Discussion
does not attempt to use even if defined. This is deliberate so allocators may use it internally within their own implementation of .
-
Declaration
boolalignedReallocate(Allocator)(ref Allocatoralloc, ref void[]b, size_ts, uinta);The default function first attempts to use . If is not defined or returns , allocates
anew block of memory of appropriate size and copies data from the old block to the new block. Finally, if defines , uses it to free the old memory block.Discussion
does not attempt to use even if defined. This is deliberate so allocators may use it internally within their own implementation of .
-
Declaration
stringforwardToMember(stringmember, string[]funs...);Forwards each of the methods in
(if defined) tofuns.member