|
BDE 4.39.x Production Release
|
#include <bslma_polymorphicallocator.h>
An STL-compatible proxy for any resource class derived from bsl::memory_resource. This class template is a pre-C++17 implementation of std::pmr::polymorphic_allocator from the C++17 Standard Library.
allocator_traits.Classes | |
| struct | rebind |
Public Types | |
| 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 | |
| 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 |
Friends | |
| bool | operator== (const polymorphic_allocator &a, const polymorphic_allocator &b) BSLS_KEYWORD_NOEXCEPT |
| bool | operator!= (const polymorphic_allocator &a, const polymorphic_allocator &b) BSLS_KEYWORD_NOEXCEPT |
| typedef const TYPE* bsl::polymorphic_allocator< TYPE >::const_pointer |
| typedef const TYPE& bsl::polymorphic_allocator< TYPE >::const_reference |
| typedef std::ptrdiff_t bsl::polymorphic_allocator< TYPE >::difference_type |
| typedef TYPE* bsl::polymorphic_allocator< TYPE >::pointer |
| typedef TYPE& bsl::polymorphic_allocator< TYPE >::reference |
| typedef std::size_t bsl::polymorphic_allocator< TYPE >::size_type |
| typedef TYPE bsl::polymorphic_allocator< TYPE >::value_type |
| bsl::polymorphic_allocator< TYPE >::polymorphic_allocator | ( | ) |
Create an allocator that will forward allocation calls to the object pointed to by bslma::Default::defaultAllocator(). Postcondition:
bslma::Default::defaultAllocator().
|
inline |
Convert a memory_resource pointer to a polymorphic_allocator object that forwards allocation calls to the object pointed to by the specified r. Postcondition:
r is null.
|
inline |
Create an allocator sharing the same resource object as the specified original. The newly constructed allocator will compare equal to original, even though they may be instantiated on different types. Postconditions:
|
inline |
|
default |
Destroy this object.
|
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.
|
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, ignoring the specified hint, which is used by other allocators as a locality hint.
std::pmr::polymorphic_allocator but it is a requirement for all C++03 allocators.
|
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 memory having sufficient size and alignment for an object 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 memory having sufficient size and alignment for an object of ELEMENT_TYPE.
|
inline |
|
inline |
Deallocate a block of memory having sufficient size and alignment to hold the specified n objects of value_type by returning it to the memory resource held by this allocator.
p is the address of a block previously allocated by a call to allocate with the same n and not yet deallocated.
|
inline |
Call the ELEMENT_TYPE destructor for the object at the specified address but do not deallocate the memory at address.
|
inline |
Return the maximum number of elements of (template parameter) TYPE that can be allocated using this allocator.
|
inline |
Return the address of the memory resource supplied on construction.
|
inline |
Return a default-constructed polymorphic_allocator.
|
friend |
Return true if memory allocated from either of the specified a or b allocators cannot necessarily be deallocated from the other; otherwise return false. This operator is selected by overload resolution if at least one argument is a specialization of polymorphic_allocator and the other is either the same specialization or is convertible to polymorphic_allocator.
polymorphic_allocator; see https://cplusplus.github.io/LWG/issue3683.
|
friend |
Return true if memory allocated from either of the specified a or b allocators can be deallocated from the other; otherwise return false. This operator is selected by overload resolution if at least one argument is a specialization of polymorphic_allocator and the other is either the same specialization or is convertible to polymorphic_allocator.
polymorphic_allocator; see https://cplusplus.github.io/LWG/issue3683.