bsl::allocator_traits<std::allocator<ALLOCATOR_TYPE>>

Specialization of allocator_traits that uses std::allocator_traits.

Synopsis

Declared in <bslma_allocatortraits.h>

template<class ALLOCATOR_TYPE>
struct allocator_traits<std::allocator<ALLOCATOR_TYPE>>;

Description

Since C++17 many of the std::allocator members are deprecated (and removed in C++20). C++23 deprecates type name members and C++26 removes them. The clang compiler on Darwin warns about any mention of those names in C++17 so this header file was producing many warnings. The specialization below "disconnects" the allocator traits of std::allocator from our own implementation and so it avoids not only warnings but possible other hassles as the std::allocator interface is morphing.

Note that we are using the standard traits (in place of ours) only on C++17 or later compilers and not C++11 (when std::allocator_traits appeared). The reason for this is that our bsl::allocator_traits supports allocator_traits::is_always_equal from C++17 in a backwards compatible manner so we cannot use pre-C++17 standard implementation that does not have that.

Type Aliases

NameDescription
rebind_alloc Alias template that rebinds the allocator to ELEMENT_TYPE.
rebind_traits allocator_traits for an allocator rebound to ELEMENT_TYPE.

Using Declarations

NameDescription
allocate Allocate uninitialized storage for n objects, optionally using hint.
allocator_type This typedef is an alias to std::allocator<ALLOCATOR_TYPE>.
const_pointer This typedef is an alias to allocator_type::const_pointer.
const_void_pointer This typedef is an alias to allocator_type::const_void_pointer.
construct Construct an object at the specified uninitialized address.
deallocate Deallocate the storage at p for n objects.
destroy Destroy the object at the specified address.
difference_type This typedef is an alias to allocator_type::difference_type.
is_always_equal true_type if two allocators always compare equal; else false_type.
max_size Return the maximum number of objects allocate can return.
pointer This typedef is an alias to allocator_type::pointer.
propagate_on_container_copy_assignment true_type if the allocator propagates on copy assignment.
propagate_on_container_move_assignment true_type if the allocator propagates on move assignment.
propagate_on_container_swap true_type if the allocator propagates on container swap.
select_on_container_copy_construction Return the allocator to use when copy-constructing a container.
size_type This typedef is an alias to allocator_type::size_type.
value_type This typedef is an alias to allocator_type::value_type.
void_pointer This typedef is an alias to allocator_type::void_pointer.