[#BloombergLP-bslma-AllocatorUtil_Traits-0f]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslma.adoc[bslma]::xref:BloombergLP/bslma/AllocatorUtil_Traits-02.adoc[AllocatorUtil&lowbar;Traits]&lt;t&lowbar;MEMORY&lowbar;RSRC*, t&lowbar;TYPE&gt;
:relfileprefix: ../../
:mrdocs:

This specialization is for allocators expressed as a pointer to class derived from `bsl&colon;&colon;memory&lowbar;resource`&period; The base class will be `bsl&colon;&colon;allocator&lowbar;traits&lt;bsl&colon;&colon;allocator&lt;t&lowbar;TYPE&gt;&gt;` if `t&lowbar;MEMORY&lowbar;RSRC` is derived from `bsl&colon;&colon;Allocator`&semi; otherwise the base class will be `bsl&colon;&colon;allocator&lowbar;traits&lt;bsl&colon;&colon;polymorphic&lowbar;allocator&lt;t&lowbar;TYPE&gt;&gt;`&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class t&lowbar;MEMORY&lowbar;RSRC,
    class t&lowbar;TYPE&gt;
struct xref:BloombergLP/bslma/AllocatorUtil_Traits-02.adoc[AllocatorUtil&lowbar;Traits]&lt;t&lowbar;MEMORY&lowbar;RSRC*, t&lowbar;TYPE&gt;
    : xref:bsl/allocator_traits-0108.adoc[bsl::allocator&lowbar;traits&lt;bsl::conditional&lt;bsl&colon;&colon;is&lowbar;convertible&lt;t&lowbar;MEMORY&lowbar;RSRC &ast;, bslma&colon;&colon;Allocator &ast;&gt;&colon;&colon;value, bsl::allocator&lt;t&lowbar;TYPE&gt;, bsl::polymorphic&lowbar;allocator&lt;t&lowbar;TYPE&gt;&gt;::type&gt;]
----

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `xref:bsl/allocator_traits-0108.adoc[bsl::allocator&lowbar;traits&lt;bsl::conditional&lt;bsl&colon;&colon;is&lowbar;convertible&lt;t&lowbar;MEMORY&lowbar;RSRC &ast;, bslma&colon;&colon;Allocator &ast;&gt;&colon;&colon;value, bsl::allocator&lt;t&lowbar;TYPE&gt;, bsl::polymorphic&lowbar;allocator&lt;t&lowbar;TYPE&gt;&gt;::type&gt;]`
| 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`] 
| Identical to, or derived from `true&lowbar;type` if two allocators of parameterized `ALLOCATOR&lowbar;TYPE` always compare equal&semi; otherwise identical to or derived from `false&lowbar;type`&period; This type is `ALLOCATOR&lowbar;TYPE&colon;&colon;is&lowbar;always&lowbar;equal` if such a type is defined, and `is&lowbar;empty&lt;ALLOCATOR&lowbar;TYPE&gt;` otherwise&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`] 
| Identical to, or derived from `true&lowbar;type` if an allocator of parameterized `ALLOCATOR&lowbar;TYPE` should be copied when a container using that `ALLOCATOR&lowbar;TYPE` is copy&hyphen;assigned&semi; otherwise identical to or derived from `false&lowbar;type`&period; This type is `ALLOCATOR&lowbar;TYPE&colon;&colon;propagate&lowbar;on&lowbar;container&lowbar;copy&lowbar;assignment` if such a type is defined, and `false&lowbar;type` otherwise&period;
| xref:bsl/allocator_traits-0108/propagate_on_container_move_assignment.adoc[`propagate&lowbar;on&lowbar;container&lowbar;move&lowbar;assignment`] 
| Identical to, or derived from `true&lowbar;type` if an allocator of parameterized `ALLOCATOR&lowbar;TYPE` should be moved when a container using that `ALLOCATOR&lowbar;TYPE` is move&hyphen;assigned&semi; otherwise identical to or derived from `false&lowbar;type`&period; This type is `ALLOCATOR&lowbar;TYPE&colon;&colon;propagate&lowbar;on&lowbar;container&lowbar;move&lowbar;assignment` if such a type is defined, and `false&lowbar;type` otherwise&period;
| xref:bsl/allocator_traits-0108/propagate_on_container_swap.adoc[`propagate&lowbar;on&lowbar;container&lowbar;swap`] 
| Identical to, or derived from `true&lowbar;type` if the allocators of parameterized `ALLOCATOR&lowbar;TYPE` should be swapped when containers using that `ALLOCATOR&lowbar;TYPE` are swapped&semi; otherwise identical to or derived from `false&lowbar;type`&period; This type is `ALLOCATOR&lowbar;TYPE&colon;&colon;propagate&lowbar;on&lowbar;container&lowbar;swap` if such a type is defined, and `false&lowbar;type` otherwise&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 object of (template parameter) type `ELEMENT&lowbar;TYPE` at the specified `elementAddr`, either by 1) calling the `construct` method on `basicAllocator` with `elemAddr` and the specified (variable number of) `arguments` if the (template parameter) type `ALLOCATOR&lowbar;TYPE` defines such a method, or 2) forwarding the specified (variable number of) `arguments` to the constructor of `ELEMENT&lowbar;TYPE` directly (and ignoring `basicAllocator`) otherwise&period; The behavior is undefined unless `elementAddr` refers to valid, uninitialized storage&period;
| xref:bsl/allocator_traits-0108/deallocate.adoc[`deallocate`] 
| Invoke `basicAllocator&period;deallocate(elementAddr, n)`&period; The behavior is undefined unless the specified `elementAddr` was returned from a prior call to the `allocate` method of an allocator that compares equal to the specified `allocator`, and has not yet been passed to a `deallocate` call of such an allocator object&period;
| xref:bsl/allocator_traits-0108/destroy.adoc[`destroy`] 
| Destroy the object of (template parameter) type `ELEMENT&lowbar;TYPE` at the specified `elementAddr`, either by 1) calling the `destroy` method on `basicAllocator` with `elemAddr` as the sole argument if the (template parameter) type `ALLOCATOR&lowbar;TYPE` defines such a method, or 2) calling the destructor directly on `elementAddr` (and ignoring `basicAllocator`) otherwise&period; The behavior is undefined unless `elementAddr` refers to a valid, constructed object&period;
| xref:bsl/allocator_traits-0108/max_size.adoc[`max&lowbar;size`] 
| Return the largest number of `value&lowbar;type` objects that could reasonably be returned by a single invocation of `allocate` for the specified `allocator`, i&period;e&period;, `allocator&period;max&lowbar;size()`&period;
| xref:bsl/allocator_traits-0108/select_on_container_copy_construction.adoc[`select&lowbar;on&lowbar;container&lowbar;copy&lowbar;construction`] 
| Return a copy of the allocator that should be used to copy&hyphen; construct one container from another container whose allocator is the specified `rhs`&period; If the parameterized `ALLOCATOR&lowbar;TYPE` defines a method `select&lowbar;on&lowbar;container&lowbar;copy&lowbar;construction`, this function returns the result of calling that method on `rhs`&semi; otherwise, this method enforces the default policy of propagating the allocator on copy construction, as is standard practice for standard allocators (i&period;e&period;, returns `rhs`)&period; Note that the specialization of this class template for `bsl&colon;&colon;allocator` (in the `bslma&lowbar;bslallocator` component) provides the alternate default behavior of _not_ propagating the allocator on copy construction (i&period;e&period;, returning a default&hyphen;constructed allocator object)&period;
|===



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