This specialization is for allocators expressed as a pointer to class derived from bsl::memory_resource. The base class will be bsl::allocator_traits<bsl::allocator<t_TYPE>> if t_MEMORY_RSRC is derived from bsl::Allocator; otherwise the base class will be bsl::allocator_traits<bsl::polymorphic_allocator<t_TYPE>>.

Synopsis

Base Classes

Name

Description

bsl::allocator_traits<bsl::conditional<bsl::is_convertible<t_MEMORY_RSRC *, bslma::Allocator *>::value, bsl::allocator<t_TYPE>, bsl::polymorphic_allocator<t_TYPE>>::type>

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

Name

Description

allocator_type

This typedef is an alias to the (template parameter) ALLOCATOR_TYPE.

const_pointer

This typedef is an alias to AllocatorTraits_ConstPointerType<ALLOCATOR_TYPE>::type.

const_void_pointer

Const void pointer type for the allocator.

difference_type

This typedef is an alias to AllocatorTraits_DifferenceType<ALLOCATOR_TYPE>::type.

is_always_equal

Identical to, or derived from true_type if two allocators of parameterized ALLOCATOR_TYPE always compare equal; otherwise identical to or derived from false_type. This type is ALLOCATOR_TYPE::is_always_equal if such a type is defined, and is_empty<ALLOCATOR_TYPE> otherwise.

pointer

This typedef is an alias to AllocatorTraits_PointerType<ALLOCATOR_TYPE>::type.

propagate_on_container_copy_assignment

Identical to, or derived from true_type if an allocator of parameterized ALLOCATOR_TYPE should be copied when a container using that ALLOCATOR_TYPE is copy‐assigned; otherwise identical to or derived from false_type. This type is ALLOCATOR_TYPE::propagate_on_container_copy_assignment if such a type is defined, and false_type otherwise.

propagate_on_container_move_assignment

Identical to, or derived from true_type if an allocator of parameterized ALLOCATOR_TYPE should be moved when a container using that ALLOCATOR_TYPE is move‐assigned; otherwise identical to or derived from false_type. This type is ALLOCATOR_TYPE::propagate_on_container_move_assignment if such a type is defined, and false_type otherwise.

propagate_on_container_swap

Identical to, or derived from true_type if the allocators of parameterized ALLOCATOR_TYPE should be swapped when containers using that ALLOCATOR_TYPE are swapped; otherwise identical to or derived from false_type. This type is ALLOCATOR_TYPE::propagate_on_container_swap if such a type is defined, and false_type otherwise.

rebind_alloc

Rebind this allocator to the specified ELEMENT_TYPE.

rebind_traits

Rebind this allocator traits type to the specified ELEMENT_TYPE.

size_type

This typedef is an alias to AllocatorTraits_SizeType<ALLOCATOR_TYPE>::type.

value_type

This typedef is an alias to ALLOCATOR_TYPE::value_type.

void_pointer

This typedef is an alias to AllocatorTraits_VoidPointerType<ALLOCATOR_TYPE>::type.

Static Member Functions

Name

Description

allocate

allocate overloads

construct

Construct an object of (template parameter) type ELEMENT_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_TYPE defines such a method, or 2) forwarding the specified (variable number of) arguments to the constructor of ELEMENT_TYPE directly (and ignoring basicAllocator) otherwise. The behavior is undefined unless elementAddr refers to valid, uninitialized storage.

deallocate

Invoke basicAllocator.deallocate(elementAddr, n). 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.

destroy

Destroy the object of (template parameter) type ELEMENT_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_TYPE defines such a method, or 2) calling the destructor directly on elementAddr (and ignoring basicAllocator) otherwise. The behavior is undefined unless elementAddr refers to a valid, constructed object.

max_size

Return the largest number of value_type objects that could reasonably be returned by a single invocation of allocate for the specified allocator, i.e., allocator.max_size().

select_on_container_copy_construction

Return a copy of the allocator that should be used to copy‐ construct one container from another container whose allocator is the specified rhs. If the parameterized ALLOCATOR_TYPE defines a method select_on_container_copy_construction, this function returns the result of calling that method on rhs; otherwise, this method enforces the default policy of propagating the allocator on copy construction, as is standard practice for standard allocators (i.e., returns rhs). Note that the specialization of this class template for bsl::allocator (in the bslma_bslallocator component) provides the alternate default behavior of not propagating the allocator on copy construction (i.e., returning a default‐constructed allocator object).

Created with MrDocs