|
BDE 4.39.x Production Release
|
#include <bslma_bslallocator.h>
An STL-compatible allocator that forwards allocation calls to an underlying mechanism object of a type derived from bslma::Allocator. This class template adheres to the allocator requirements defined in section [allocator.requirements] and implements a superset of the std::pmr::polymorphic_allocator class template described in section [mem.poly.allocator.class] of the C++ standard and may be used to instantiate any [container] class template that follows the STL allocator protocol. The allocation mechanism is chosen at run-time, giving the programmer run-time control over how a container allocates and frees memory.
Classes | |
| struct | rebind |
Public Types | |
| typedef TYPE | value_type |
| typedef value_type & | reference |
| typedef value_type const & | const_reference |
| typedef BaseTraits::size_type | size_type |
| typedef BaseTraits::difference_type | difference_type |
| typedef BaseTraits::pointer | pointer |
| typedef BaseTraits::const_pointer | const_pointer |
| typedef BaseTraits::void_pointer | void_pointer |
| typedef BaseTraits::const_void_pointer | const_void_pointer |
Public Types inherited from bsl::polymorphic_allocator< TYPE > | |
| typedef std::size_t | size_type |
| typedef std::ptrdiff_t | difference_type |
| typedef TYPE * | pointer |
| typedef const TYPE * | const_pointer |
| typedef TYPE & | reference |
| typedef const TYPE & | const_reference |
| typedef TYPE | value_type |
Public Member Functions | |
| BSLMF_NESTED_TRAIT_DECLARATION (allocator, BloombergLP::bslmf::IsBitwiseCopyable) | |
| BSLMF_NESTED_TRAIT_DECLARATION (allocator, BloombergLP::bslmf::IsBitwiseEqualityComparable) | |
| allocator () | |
| allocator (BloombergLP::bslma::Allocator *mechanism) | |
| allocator (const allocator &original) BSLS_KEYWORD_NOEXCEPT | |
| template<class ANY_TYPE > | |
| allocator (const allocator< ANY_TYPE > &original) BSLS_KEYWORD_NOEXCEPT | |
| ~allocator ()=default | |
| BSLMA_BSLALLOCATOR_DEPRECATE_ASSIGN allocator & | operator= (const allocator &rhs) |
| BSLS_ANNOTATION_NODISCARD pointer | allocate (size_type n, const void *hint=0) |
| void | deallocate (TYPE *p, std::size_t n=1) |
| template<class ELEMENT_TYPE > | |
| void | construct (ELEMENT_TYPE *address) |
| template<class ELEMENT_TYPE , class ARG1 , class... ARGS> | |
| void | construct (ELEMENT_TYPE *address, ARG1 &argument1, ARGS &&... arguments) |
| template<class ELEMENT_TYPE , class ARG1 , class... ARGS> | |
| void | construct (ELEMENT_TYPE *address, BSLS_COMPILERFEATURES_FORWARD_REF(ARG1) argument1, ARGS &&... arguments) |
| template<class ELEMENT_TYPE > | |
| void | destroy (ELEMENT_TYPE *address) |
| pointer | address (reference x) const |
| const_pointer | address (const_reference x) const |
| BSLS_KEYWORD_CONSTEXPR size_type | max_size () const |
| BloombergLP::bslma::Allocator * | mechanism () const |
| allocator | select_on_container_copy_construction () const |
Public Member Functions inherited from bsl::polymorphic_allocator< TYPE > | |
| polymorphic_allocator () BSLS_KEYWORD_NOEXCEPT | |
| polymorphic_allocator (memory_resource *r) | |
| polymorphic_allocator (const polymorphic_allocator &original) BSLS_KEYWORD_NOEXCEPT | |
| template<class ANY_TYPE > | |
| polymorphic_allocator (const polymorphic_allocator< ANY_TYPE > &original) BSLS_KEYWORD_NOEXCEPT | |
| ~polymorphic_allocator ()=default | |
| BSLS_ANNOTATION_NODISCARD TYPE * | allocate (std::size_t n) |
| BSLS_ANNOTATION_NODISCARD TYPE * | allocate (std::size_t n, const void *hint) |
| void | deallocate (TYPE *p, std::size_t n) |
| template<class ELEMENT_TYPE > | |
| void | construct (ELEMENT_TYPE *address) |
| template<class ELEMENT_TYPE , class ARG1 , class... ARGS> | |
| void | construct (ELEMENT_TYPE *address, ARG1 &argument1, ARGS &&... arguments) |
| template<class ELEMENT_TYPE , class ARG1 , class... ARGS> | |
| void | construct (ELEMENT_TYPE *address, BSLS_COMPILERFEATURES_FORWARD_REF(ARG1) argument1, ARGS &&... arguments) |
| template<class ELEMENT_TYPE > | |
| void | destroy (ELEMENT_TYPE *address) |
| pointer | address (reference x) const |
| const_pointer | address (const_reference x) const |
| BSLS_KEYWORD_CONSTEXPR size_type | max_size () const |
| memory_resource * | resource () const |
| polymorphic_allocator | select_on_container_copy_construction () const |
| typedef BaseTraits::const_pointer bsl::allocator< TYPE >::const_pointer |
| typedef value_type const& bsl::allocator< TYPE >::const_reference |
| typedef BaseTraits::const_void_pointer bsl::allocator< TYPE >::const_void_pointer |
| typedef BaseTraits::difference_type bsl::allocator< TYPE >::difference_type |
| typedef BaseTraits::pointer bsl::allocator< TYPE >::pointer |
| typedef value_type& bsl::allocator< TYPE >::reference |
| typedef BaseTraits::size_type bsl::allocator< TYPE >::size_type |
| typedef TYPE bsl::allocator< TYPE >::value_type |
| typedef BaseTraits::void_pointer bsl::allocator< TYPE >::void_pointer |
|
inline |
Create an allocator that will forward allocation calls to the object pointed to by bslma::Default::defaultAllocator(). Postcondition:
|
inline |
Convert a bslma::Allocator pointer to an allocator object that forwards allocation calls to the object pointed to by the specified mechanism. If mechanism is 0, then the currently installed default allocator is used instead. Postcondition:
|
inline |
|
inline |
Create an allocator sharing the same mechanism object as the specified original. The newly constructed allocator will compare equal to original, even though they may be instantiated on different types. Postconditions:
|
default |
Destroy this object.
mechanism().
|
inline |
|
inline |
Return the address of the object referred to by the specified x reference, even if the (template parameter) TYPE overloads the unary operator&.
|
inline |
Return a block of memory having sufficient size and alignment to hold the specified n objects of value_type, allocated from the memory resource held by this allocator. Optionally specify a hint, which is ignored by this allocator type but theoretically used by other allocators as an aid for optimizing locality.
| bsl::allocator< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION | ( | allocator< TYPE > | , |
| BloombergLP::bslmf::IsBitwiseCopyable | |||
| ) |
| bsl::allocator< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION | ( | allocator< TYPE > | , |
| BloombergLP::bslmf::IsBitwiseEqualityComparable | |||
| ) |
|
inline |
Create a default-constructed object of (template parameter) ELEMENT_TYPE at the specified address. If ELEMENT_TYPE supports bslma-style allocation, this allocator passes itself to the extended default constructor. If the constructor throws, the memory at address is left in an unspecified state.
address refers to a block of sufficient size and properly aligned for objects of ELEMENT_TYPE.
|
inline |
Create an object of (template parameter) ELEMENT_TYPE at the specified address, constructed by forwarding the specified argument1 and the (variable number of) additional specified arguments to the corresponding constructor of ELEMENT_TYPE. If ELEMENT_TYPE supports bslma-style allocation, this allocator passes itself to the constructor. If the constructor throws, the memory at address is left in an unspecified state.
arguments parameter pack is const-qualified when forwarded to the ELEMENT_TYPE constructor; only argument1 can be forwarded as an unqualified lvalue. address refers to a block of sufficient size and properly aligned for objects of ELEMENT_TYPE.
|
inline |
|
inline |
Deallocate a block of memory at the specified p address by returning it to the memory resource held by this allocator. Optionally specify the number of objects, n, to deallocate.
p is the address of a block previously allocated by a call to allocate with the same n from a copy of this allocator having the same value_type and not yet deallocated.
|
inline |
Call the TYPE destructor for the object pointed to by the specified address. Do not directly deallocate any memory.
|
inline |
Return the maximum number of elements of (template parameter) TYPE that can be allocated using this allocator.
|
inline |
Return a pointer to the mechanism object to which this proxy forwards allocation and deallocation calls.
|
inline |
Modify this allocator to use the same mechanism as the specified rhs allocator and return a modifiable reference to this object.
bsl::allocator objects should never be assigned at runtime, but, in the absence of if constexpr, such assignments can sometimes be found legitimately in dead branches (branches that are never taken at runtime) within function templates; ideally, such code would be replaced by more sophisticated metaprogramming that avoided calls to this operator entirely. Invoking this assignment will result in a review error unless rhs == *this, i.e., when the assignment would be a no-op. In the future, the review error may be replaced with an a hard assertion failure.bsl::allocator should not be assigned.
|
inline |
Return a default-constructed allocator.