BloombergLP::bslma::AllocatorUtil

Namespace for utility functions on allocators

Synopsis

Declared in <bslma_allocatorutil.h>

struct AllocatorUtil;

Static Member Functions

NameDescription
adapt adapt overloads
allocateBytes Return a pointer to a block of raw memory allocated from the specified allocator having the specified nbytes size and optionally specified alignment. If alignment is not specified, the natural alignment for an object of size nbytes is used. If alignment is larger than the largest supported alignment for t_ALLOCATOR, either the block will be aligned to the maximum supported alignment or an exception will be thrown; the specific choice of behavior is determined by the allocator. For polymorphic allocators the behavior of extended alignment is determined by the memory resource, whereas for non-polymorphic allocators, the alignment is always truncated to the maximum non-extended alignment.
allocateObject Return a pointer to a block of raw memory allocated from the specified allocator having a size and alignment appropriate for an object of (templatize parameter) t_TYPE. Optionally specify n for the number of objects; otherwise space for a single object is allocated. Since t_TYPE cannot be deduced from the function parameters, it must be supplied explicitly (in <> brackets) by the caller.
assign assign overloads
deallocateBytes Give back, to the specified allocator, the block of raw memory at the specified p address having the specified nbytes size and optionally specified alignment. If alignment is not specified, the natural alignment for an object of size nbytes is used. The behavior is undefined unless p refers to a block having the same size and alignment previously allocated from a copy of allocator and not yet deallocated.
deallocateObject Return to the specified allocator a block of raw memory at the specified p address that is suitably sized and aligned to hold an object of (templatize parameter) t_TYPE. Optionally specify n for the number of objects; otherwise a single object is assumed. The behavior is undefined unless p refers to a block with the same type and number of objects previously allocated from a copy of allocator and not yet deallocated.
deleteObject Destroy the object at the specified p address and return the block of memory at p to the specified allocator. The behavior is undefined unless p refers to a fully constructed object allocated from a copy of allocator and not yet destroyed or deallocated.
newObject newObject overloads
swap swap overloads