[#BloombergLP-bslma-AllocatorUtil] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslma.adoc[bslma]::AllocatorUtil :relfileprefix: ../../ :mrdocs: Namespace for utility functions on allocators == Synopsis Declared in `<bslma_allocatorutil.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- struct AllocatorUtil; ---- == Static Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslma/AllocatorUtil/adapt-08.adoc[`adapt`] | `adapt` overloads | xref:BloombergLP/bslma/AllocatorUtil/allocateBytes.adoc[`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. | xref:BloombergLP/bslma/AllocatorUtil/allocateObject.adoc[`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. | xref:BloombergLP/bslma/AllocatorUtil/assign-05.adoc[`assign`] | `assign` overloads | xref:BloombergLP/bslma/AllocatorUtil/deallocateBytes.adoc[`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. | xref:BloombergLP/bslma/AllocatorUtil/deallocateObject.adoc[`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. | xref:BloombergLP/bslma/AllocatorUtil/deleteObject.adoc[`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. | xref:BloombergLP/bslma/AllocatorUtil/newObject-08.adoc[`newObject`] | `newObject` overloads | xref:BloombergLP/bslma/AllocatorUtil/swap-0f.adoc[`swap`] | `swap` overloads |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#