[#bsl-allocator_traits-0108]
= xref:bsl.adoc[bsl]::allocator&lowbar;traits
:relfileprefix: ../
:mrdocs:

Uniform interface to nested types and operations of any allocator&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class ALLOCATOR&lowbar;TYPE&gt;
struct allocator&lowbar;traits;
----

== Description

This class supports the complete interface of the C&plus;&plus;11 `allocator&lowbar;traits` class template, which provides a uniform mechanism for accessing nested types within, and operations on, any standard&hyphen;conforming allocator&period; A specialization of this class template for `bsl&colon;&colon;allocator` provides support for Bloomberg&apos;s `bslma` allocator model (see the `bslma&lowbar;bslallocator` component for more details)&period; In C&plus;&plus;11 compilation environments, the `construct` methods forward to the allocator&apos;s `construct` method if such a method matching the (variable number of) specified constructor arguments exists&semi; otherwise, the `construct` method falls back to invoking the constructor of the element type directly&period; In C&plus;&plus;03 compilation environments, there is no reliable way to detect if the type provide a method that matches a (variable number of) specified arguments&semi; therefore, we require that standard allocator types define `construct` methods taking a variable number of arguments in those environments&period; This implementation is not fully&hyphen;standard&hyphen;conforming in that it does not support deduce data types that are not specified in the allocator&period;

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:bsl/allocator_traits-0108/allocator_type.adoc[`allocator&lowbar;type`] 
| This `typedef` is an alias to the (template parameter) `ALLOCATOR&lowbar;TYPE`&period;
| xref:bsl/allocator_traits-0108/const_pointer.adoc[`const&lowbar;pointer`] 
| This `typedef` is an alias to `AllocatorTraits&lowbar;ConstPointerType&lt;ALLOCATOR&lowbar;TYPE&gt;&colon;&colon;type`&period;
| xref:bsl/allocator_traits-0108/const_void_pointer.adoc[`const&lowbar;void&lowbar;pointer`] 
| Const void pointer type for the allocator&period;
| xref:bsl/allocator_traits-0108/difference_type.adoc[`difference&lowbar;type`] 
| This `typedef` is an alias to `AllocatorTraits&lowbar;DifferenceType&lt;ALLOCATOR&lowbar;TYPE&gt;&colon;&colon;type`&period;
| xref:bsl/allocator_traits-0108/is_always_equal.adoc[`is&lowbar;always&lowbar;equal`] 
| `true&lowbar;type` if two allocators always compare equal&semi; else `false&lowbar;type`&period;
| xref:bsl/allocator_traits-0108/pointer.adoc[`pointer`] 
| This `typedef` is an alias to `AllocatorTraits&lowbar;PointerType&lt;ALLOCATOR&lowbar;TYPE&gt;&colon;&colon;type`&period;
| xref:bsl/allocator_traits-0108/propagate_on_container_copy_assignment.adoc[`propagate&lowbar;on&lowbar;container&lowbar;copy&lowbar;assignment`] 
| `true&lowbar;type` if the allocator propagates on copy assignment&period;
| xref:bsl/allocator_traits-0108/propagate_on_container_move_assignment.adoc[`propagate&lowbar;on&lowbar;container&lowbar;move&lowbar;assignment`] 
| `true&lowbar;type` if the allocator propagates on move assignment&period;
| xref:bsl/allocator_traits-0108/propagate_on_container_swap.adoc[`propagate&lowbar;on&lowbar;container&lowbar;swap`] 
| `true&lowbar;type` if the allocator propagates on container swap&period;
| xref:bsl/allocator_traits-0108/rebind_alloc.adoc[`rebind&lowbar;alloc`] 
| Rebind this allocator to the specified `ELEMENT&lowbar;TYPE`&period;
| xref:bsl/allocator_traits-0108/rebind_traits.adoc[`rebind&lowbar;traits`] 
| Rebind this allocator traits type to the specified `ELEMENT&lowbar;TYPE`&period;
| xref:bsl/allocator_traits-0108/size_type.adoc[`size&lowbar;type`] 
| This `typedef` is an alias to `AllocatorTraits&lowbar;SizeType&lt;ALLOCATOR&lowbar;TYPE&gt;&colon;&colon;type`&period;
| xref:bsl/allocator_traits-0108/value_type.adoc[`value&lowbar;type`] 
| This `typedef` is an alias to `ALLOCATOR&lowbar;TYPE&colon;&colon;value&lowbar;type`&period;
| xref:bsl/allocator_traits-0108/void_pointer.adoc[`void&lowbar;pointer`] 
| This `typedef` is an alias to `AllocatorTraits&lowbar;VoidPointerType&lt;ALLOCATOR&lowbar;TYPE&gt;&colon;&colon;type`&period;
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/allocator_traits-0108/allocate-03.adoc[`allocate`] 
| `allocate` overloads
| xref:bsl/allocator_traits-0108/construct.adoc[`construct`] 
| Construct an `ELEMENT&lowbar;TYPE` object at `elementAddr`&period;
| xref:bsl/allocator_traits-0108/deallocate.adoc[`deallocate`] 
| Deallocate the storage at `elementAddr` for `n` objects&period;
| xref:bsl/allocator_traits-0108/destroy.adoc[`destroy`] 
| Destroy the `ELEMENT&lowbar;TYPE` object at `elementAddr`&period;
| xref:bsl/allocator_traits-0108/max_size.adoc[`max&lowbar;size`] 
| Return the maximum number of objects `allocate` can return&period;
| xref:bsl/allocator_traits-0108/select_on_container_copy_construction.adoc[`select&lowbar;on&lowbar;container&lowbar;copy&lowbar;construction`] 
| Return the allocator to use when copy&hyphen;constructing a container&period;
|===


== Specializations

[cols="1,4"]
|===
| Name| Description
| xref:bsl/allocator_traits-05e.adoc[`allocator&lowbar;traits&lt;allocator&lt;TYPE&gt;&gt;`] 
| Specialization of `allocator&lowbar;traits` for `bsl&colon;&colon;allocator`&period;
| xref:bsl/allocator_traits-0ae.adoc[`allocator&lowbar;traits&lt;std::allocator&lt;ALLOCATOR&lowbar;TYPE&gt;&gt;`] 
| Specialization of `allocator&lowbar;traits` that uses `std&colon;&colon;allocator&lowbar;traits`&period;
| xref:bsl/allocator_traits-0a4.adoc[`allocator&lowbar;traits&lt;ALLOCATOR&lowbar;TYPE*&gt;`] 
| Empty specialization of `allocator&lowbar;traits` for pointer allocator types&period;
|===


== Derived Classes

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslma/AllocatorUtil_Traits-0f.adoc[`AllocatorUtil&lowbar;Traits&lt;t&lowbar;MEMORY&lowbar;RSRC*, t&lowbar;TYPE&gt;`] 
| Traits for an allocator expressed as a pointer to a memory resource&period;
|===


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