[#bsl-allocator-0df]
= xref:bsl.adoc[bsl]::allocator
:relfileprefix: ../
:mrdocs:

An STL&hyphen;compatible allocator that forwards to a `bslma&colon;&colon;Allocator`&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class TYPE = polymorphic&lowbar;allocator&lt;&gt;::value&lowbar;type&gt;
class allocator
    : public xref:bsl/polymorphic_allocator.adoc[polymorphic&lowbar;allocator&lt;TYPE&gt;]
----

== Description

An STL&hyphen;compatible allocator that forwards allocation calls to an underlying mechanism object of a type derived from `bslma&colon;&colon;Allocator`&period; This class template adheres to the allocator requirements defined in section &lsqb;allocator&period;requirements&rsqb;and implements a superset of the `std&colon;&colon;pmr&colon;&colon;polymorphic&lowbar;allocator` class template described in section &lsqb;mem&period;poly&period;allocator&period;class&rsqb;of the C&plus;&plus; standard and may be used to instantiate any &lsqb;container&rsqb;class template that follows the STL allocator protocol&period; The allocation mechanism is chosen at run&hyphen;time, giving the programmer run&hyphen;time control over how a container allocates and frees memory&period;

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `xref:bsl/polymorphic_allocator.adoc[polymorphic&lowbar;allocator&lt;TYPE&gt;]`
| Alias for `std&colon;&colon;pmr&colon;&colon;polymorphic&lowbar;allocator` in the `bsl` namespace&period;
|===

== Types

[cols="1,4"]
|===
| Name| Description
| xref:bsl/allocator-0df/rebind.adoc[`rebind`] 
| Rebind this allocator to another type&period;
|===


== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:bsl/allocator-0df/const_pointer.adoc[`const&lowbar;pointer`] 
| This `typedef` is an alias to `BaseTraits&colon;&colon;const&lowbar;pointer`&period;
| xref:bsl/allocator-0df/const_reference.adoc[`const&lowbar;reference`] 
| This `typedef` is an alias to a constant `value&lowbar;type` reference&period;
| xref:bsl/allocator-0df/const_void_pointer.adoc[`const&lowbar;void&lowbar;pointer`] 
| This `typedef` is an alias to `BaseTraits&colon;&colon;const&lowbar;void&lowbar;pointer`&period;
| xref:bsl/allocator-0df/difference_type.adoc[`difference&lowbar;type`] 
| Difference type for allocations from this allocator&period;
| xref:bsl/allocator-0df/pointer.adoc[`pointer`] 
| This `typedef` is an alias to `BaseTraits&colon;&colon;pointer`&period;
| xref:bsl/allocator-0df/reference.adoc[`reference`] 
| This `typedef` is an alias to a modifiable `value&lowbar;type` reference&period;
| xref:bsl/allocator-0df/size_type.adoc[`size&lowbar;type`] 
| Size type for allocations from this allocator&period;
| xref:bsl/allocator-0df/value_type.adoc[`value&lowbar;type`] 
| This `typedef` is an alias to the (template parameter) `TYPE`&period;
| xref:bsl/allocator-0df/void_pointer.adoc[`void&lowbar;pointer`] 
| This `typedef` is an alias to `BaseTraits&colon;&colon;void&lowbar;pointer`&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/allocator-0df/2constructor-0f.adoc[`allocator`]         [.small]#[constructor]#
| Create an allocator that uses the default allocator mechanism&period;
| xref:bsl/allocator-0df/2constructor-0c.adoc[`allocator`]         [.small]#[constructor]#
| Create an allocator that copies `original`&period;
| xref:bsl/allocator-0df/2constructor-0bc.adoc[`allocator`]         [.small]#[constructor]#
| Create an allocator sharing the mechanism of the specified `original`&period;
| xref:bsl/allocator-0df/2constructor-0b9.adoc[`allocator`]         [.small]#[constructor]#
| Convert a `bslma&colon;&colon;Allocator` pointer to an `allocator` object&period;
| xref:bsl/allocator-0df/operator_assign.adoc[`operator&equals;`] 
| Assign this allocator from the specified `rhs` if it is a no&hyphen;op assignment&period;
| xref:bsl/allocator-0df/address-08.adoc[`address`] 
| Return the address of the specified object `x`&period;
| xref:bsl/allocator-0df/address-04.adoc[`address`] 
| Return the address of the specified object `x`&period;
| xref:bsl/allocator-0df/allocate.adoc[`allocate`] 
| Return storage for `n` objects of `value&lowbar;type`&period;
| xref:bsl/allocator-0df/construct-00.adoc[`construct`] 
| Default&hyphen;construct an `ELEMENT&lowbar;TYPE` object at the specified `address`&period;
| xref:bsl/allocator-0df/construct-08.adoc[`construct`] 
| Construct an `ELEMENT&lowbar;TYPE` at `address` from the arguments&period;
| xref:bsl/allocator-0df/construct-0e.adoc[`construct`] 
| Construct an `ELEMENT&lowbar;TYPE` at `address` using perfect forwarding&period;
| xref:bsl/allocator-0df/deallocate.adoc[`deallocate`] 
| Deallocate the memory block at the specified `p` address&period;
| xref:bsl/allocator-0df/destroy.adoc[`destroy`] 
| Call the destructor for the object at the specified `address`&period;
| xref:bsl/allocator-0df/max_size.adoc[`max&lowbar;size`] 
| Return the maximum number of elements allocatable by this allocator&period;
| xref:bsl/allocator-0df/mechanism.adoc[`mechanism`] 
| Return a pointer to the mechanism object to which this proxy forwards allocation and deallocation calls&period;
| xref:bsl/allocator-0df/select_on_container_copy_construction.adoc[`select&lowbar;on&lowbar;container&lowbar;copy&lowbar;construction`] 
| Return a default&hyphen;constructed allocator&period;
| xref:bsl/allocator-0df/2conversion-0e.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;allocator, IsBitwiseCopyable&gt;`] 
| Return a tag declaring that this allocator is bitwise copyable&period;
| xref:bsl/allocator-0df/2conversion-04.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;allocator, IsBitwiseEqualityComparable&gt;`] 
| Declare that `allocator` is bitwise equality comparable&period;
|===


== Specializations

[cols="1,4"]
|===
| Name| Description
| xref:bsl/allocator-0a.adoc[`allocator&lt;void&gt;`] 
| Specialization of `allocator` for `void`&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/format-0cb.adoc[`format`]
| Format `args` according to `fmtStr` using `alloc` and locale `loc`&period;
| xref:bsl/format-0ce.adoc[`format`]
| Format `args` according to `fmtStr` using allocator `alloc`&period;
| xref:bsl/format-0d.adoc[`format`]
| Format `args` according to `fmtStr` using `alloc` and locale `loc`&period;
| xref:bsl/format-0e.adoc[`format`]
| Format `args` according to `fmtStr` using allocator `alloc`&period;
| xref:bsl/vformat-00b.adoc[`vformat`]
| Format `args` according to `fmtStr` using allocator and locale&period;
| xref:bsl/vformat-0c3.adoc[`vformat`]
| Format `args` according to `fmtStr` using the given allocator&period;
| xref:bsl/vformat-0eb.adoc[`vformat`]
| Format `args` according to `fmtStr` using the given allocator&period;
| xref:bsl/vformat-0ef.adoc[`vformat`]
| Format `args` according to `fmtStr` using allocator and locale&period;
| xref:BloombergLP/bslfmt/format-06.adoc[`&colon;&colon;BloombergLP&colon;&colon;bslfmt&colon;&colon;format`]
| Format `args` according to `fmtStr` using allocator `alloc`&period;
| xref:BloombergLP/bslfmt/format-099.adoc[`&colon;&colon;BloombergLP&colon;&colon;bslfmt&colon;&colon;format`]
| Format `args` according to `fmtStr` using allocator `alloc`&period;
| xref:BloombergLP/bslfmt/vformat-0c.adoc[`&colon;&colon;BloombergLP&colon;&colon;bslfmt&colon;&colon;vformat`]
| Format `args` according to `fmtStr` using the given allocator&period;
| xref:BloombergLP/bslfmt/vformat-0f.adoc[`&colon;&colon;BloombergLP&colon;&colon;bslfmt&colon;&colon;vformat`]
| Format `args` according to `fmtStr` using the given allocator&period;
|===

== Derived Classes

[cols="1,4"]
|===
| Name| Description
| xref:bsl/allocator-0a.adoc[`allocator&lt;void&gt;`] 
| Specialization of `allocator` for `void`&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
