[#BloombergLP-bslma-AllocatorUtil]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslma.adoc[bslma]::AllocatorUtil
:relfileprefix: ../../
:mrdocs:

Namespace for utility functions on allocators

== Synopsis

Declared in `&lt;bslma&lowbar;allocatorutil&period;h&gt;`

[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`&period; If `alignment` is not specified, the natural alignment for an object of size `nbytes` is used&period; If `alignment` is larger than the largest supported alignment for `t&lowbar;ALLOCATOR`, either the block will be aligned to the maximum supported alignment or an exception will be thrown&semi; the specific choice of behavior is determined by the allocator&period; For polymorphic allocators the behavior of extended alignment is determined by the memory resource, whereas for non&hyphen;polymorphic allocators, the alignment is always truncated to the maximum non&hyphen;extended alignment&period;
| 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&lowbar;TYPE`&period; Optionally specify `n` for the number of objects&semi; otherwise space for a single object is allocated&period; Since `t&lowbar;TYPE` cannot be deduced from the function parameters, it must be supplied explicitly (in `&lt;&gt;` brackets) by the caller&period;
| 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`&period; If `alignment` is not specified, the natural alignment for an object of size `nbytes` is used&period; 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&period;
| 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&lowbar;TYPE`&period; Optionally specify `n` for the number of objects&semi; otherwise a single object is assumed&period; 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&period;
| 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`&period; The behavior is undefined unless `p` refers to a fully constructed object allocated from a copy of `allocator` and not yet destroyed or deallocated&period;
| 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]#
