[#bsl-allocator_traits-0108] = xref:bsl.adoc[bsl]::allocator_traits :relfileprefix: ../ :mrdocs: Uniform interface to nested types and operations of any allocator. == Synopsis Declared in `<bslma_allocatortraits.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class ALLOCATOR_TYPE> struct allocator_traits; ---- == Description This class supports the complete interface of the C++11 `allocator_traits` class template, which provides a uniform mechanism for accessing nested types within, and operations on, any standard‐conforming allocator. A specialization of this class template for `bsl::allocator` provides support for Bloomberg's `bslma` allocator model (see the `bslma_bslallocator` component for more details). In C++11 compilation environments, the `construct` methods forward to the allocator's `construct` method if such a method matching the (variable number of) specified constructor arguments exists; otherwise, the `construct` method falls back to invoking the constructor of the element type directly. In C++03 compilation environments, there is no reliable way to detect if the type provide a method that matches a (variable number of) specified arguments; therefore, we require that standard allocator types define `construct` methods taking a variable number of arguments in those environments. This implementation is not fully‐standard‐conforming in that it does not support deduce data types that are not specified in the allocator. == Type Aliases [cols="1,4"] |=== | Name| Description | xref:bsl/allocator_traits-0108/allocator_type.adoc[`allocator_type`] | This `typedef` is an alias to the (template parameter) `ALLOCATOR_TYPE`. | xref:bsl/allocator_traits-0108/const_pointer.adoc[`const_pointer`] | This `typedef` is an alias to `AllocatorTraits_ConstPointerType<ALLOCATOR_TYPE>::type`. | xref:bsl/allocator_traits-0108/const_void_pointer.adoc[`const_void_pointer`] | Const void pointer type for the allocator. | xref:bsl/allocator_traits-0108/difference_type.adoc[`difference_type`] | This `typedef` is an alias to `AllocatorTraits_DifferenceType<ALLOCATOR_TYPE>::type`. | xref:bsl/allocator_traits-0108/is_always_equal.adoc[`is_always_equal`] | `true_type` if two allocators always compare equal; else `false_type`. | xref:bsl/allocator_traits-0108/pointer.adoc[`pointer`] | This `typedef` is an alias to `AllocatorTraits_PointerType<ALLOCATOR_TYPE>::type`. | xref:bsl/allocator_traits-0108/propagate_on_container_copy_assignment.adoc[`propagate_on_container_copy_assignment`] | `true_type` if the allocator propagates on copy assignment. | xref:bsl/allocator_traits-0108/propagate_on_container_move_assignment.adoc[`propagate_on_container_move_assignment`] | `true_type` if the allocator propagates on move assignment. | xref:bsl/allocator_traits-0108/propagate_on_container_swap.adoc[`propagate_on_container_swap`] | `true_type` if the allocator propagates on container swap. | xref:bsl/allocator_traits-0108/rebind_alloc.adoc[`rebind_alloc`] | Rebind this allocator to the specified `ELEMENT_TYPE`. | xref:bsl/allocator_traits-0108/rebind_traits.adoc[`rebind_traits`] | Rebind this allocator traits type to the specified `ELEMENT_TYPE`. | xref:bsl/allocator_traits-0108/size_type.adoc[`size_type`] | This `typedef` is an alias to `AllocatorTraits_SizeType<ALLOCATOR_TYPE>::type`. | xref:bsl/allocator_traits-0108/value_type.adoc[`value_type`] | This `typedef` is an alias to `ALLOCATOR_TYPE::value_type`. | xref:bsl/allocator_traits-0108/void_pointer.adoc[`void_pointer`] | This `typedef` is an alias to `AllocatorTraits_VoidPointerType<ALLOCATOR_TYPE>::type`. |=== == 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_TYPE` object at `elementAddr`. | xref:bsl/allocator_traits-0108/deallocate.adoc[`deallocate`] | Deallocate the storage at `elementAddr` for `n` objects. | xref:bsl/allocator_traits-0108/destroy.adoc[`destroy`] | Destroy the `ELEMENT_TYPE` object at `elementAddr`. | xref:bsl/allocator_traits-0108/max_size.adoc[`max_size`] | Return the maximum number of objects `allocate` can return. | xref:bsl/allocator_traits-0108/select_on_container_copy_construction.adoc[`select_on_container_copy_construction`] | Return the allocator to use when copy‐constructing a container. |=== == Specializations [cols="1,4"] |=== | Name| Description | xref:bsl/allocator_traits-05e.adoc[`allocator_traits<allocator<TYPE>>`] | Specialization of `allocator_traits` for `bsl::allocator`. | xref:bsl/allocator_traits-0ae.adoc[`allocator_traits<std::allocator<ALLOCATOR_TYPE>>`] | Specialization of `allocator_traits` that uses `std::allocator_traits`. | xref:bsl/allocator_traits-0a4.adoc[`allocator_traits<ALLOCATOR_TYPE*>`] | Empty specialization of `allocator_traits` for pointer allocator types. |=== == Derived Classes [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslma/AllocatorUtil_Traits-0f.adoc[`AllocatorUtil_Traits<t_MEMORY_RSRC*, t_TYPE>`] | Traits for an allocator expressed as a pointer to a memory resource. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#