template<class TYPE, bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION = true, bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT = true, bool PROPAGATE_ON_CONTAINER_SWAP = true, bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT = true, bool IS_ALWAYS_EQUAL = false>
class bsltf::StdStatefulAllocator< TYPE, PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION, PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT, PROPAGATE_ON_CONTAINER_SWAP, PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT, IS_ALWAYS_EQUAL >
This allocator implements the minimal interface to comply with section 17.6.3.5 ([allocator.requirements]) of the C++11 standard, while maintaining a distinct object state - in this case a wrapped pointer to a bslma::Allocator. The template is configurable to control its allocator propagation properties, but does not support the BDE "scoped" allocator model, as scoped allocators should never propagate. Instances of this allocator delegate their operations to the wrapped allocator that constitutes its state.
- Note
- Note that while we define the various traits used by the C++11 allocator traits facility, they actually mean very little for this component, as it is the consumer of the allocator's responsibility to check and apply the traits correctly, typically by using
bsl::allocator_traits to perform all memory allocation tasks rather than using the allocator directly. The PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION flag is consumed directly though, in the static member function select_on_container_copy_construction .
See bsltf_stdstatefulallocator
template<class TYPE , bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION, bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT, bool PROPAGATE_ON_CONTAINER_SWAP, bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT, bool IS_ALWAYS_EQUAL>
template<class BDE_OTHER_TYPE >
| bsltf::StdStatefulAllocator< TYPE, PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION, PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT, PROPAGATE_ON_CONTAINER_SWAP, PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT, IS_ALWAYS_EQUAL >::StdStatefulAllocator |
( |
const StdStatefulAllocator< BDE_OTHER_TYPE, PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION, PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT, PROPAGATE_ON_CONTAINER_SWAP, PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT, IS_ALWAYS_EQUAL > & |
original | ) |
|
|
inline |
template<class TYPE , bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION, bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT, bool PROPAGATE_ON_CONTAINER_SWAP, bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT, bool IS_ALWAYS_EQUAL>
Allocate enough (properly aligned) space for the specified numElements of the (template parameter) type TYPE. If the underlying bslma::Allocator is unable to fulfill the allocation request, an exception (typically bsl::bad_alloc) will be thrown.
template<class TYPE , bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION, bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT, bool PROPAGATE_ON_CONTAINER_SWAP, bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT, bool IS_ALWAYS_EQUAL>
template<class ELEMENT_TYPE , class... Args>
| void bsltf::StdStatefulAllocator< TYPE, PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION, PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT, PROPAGATE_ON_CONTAINER_SWAP, PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT, IS_ALWAYS_EQUAL >::construct |
( |
ELEMENT_TYPE * |
address, |
|
|
Args &&... |
arguments |
|
) |
| |
|
inline |
Construct an object of the (template parameter) ELEMENT_TYPE, by forwarding the specified (variable number of) arguments to the corresponding constructor of ELEMENT_TYPE, at the specified uninitialized memory address.
- Precondition
- The behavior is undefined unless
address is properly aligned for objects of ELEMENT_TYPE.
template<class TYPE , bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION, bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT, bool PROPAGATE_ON_CONTAINER_SWAP, bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT, bool IS_ALWAYS_EQUAL>
| void bsltf::StdStatefulAllocator< TYPE, PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION, PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT, PROPAGATE_ON_CONTAINER_SWAP, PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT, IS_ALWAYS_EQUAL >::deallocate |
( |
TYPE * |
address, |
|
|
bslma::Allocator::size_type |
numElements |
|
) |
| |
|
inline |
Return memory previously allocated at the specified address for numElements back to this allocator. The numElements argument is ignored by this allocator type.
- Precondition
- The behavior is undefined unless
address was allocated using this allocator object and has not already been deallocated.
template<class TYPE , bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION, bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT, bool PROPAGATE_ON_CONTAINER_SWAP, bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT, bool IS_ALWAYS_EQUAL>
template<class ELEMENT_TYPE >
| void bsltf::StdStatefulAllocator< TYPE, PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION, PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT, PROPAGATE_ON_CONTAINER_SWAP, PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT, IS_ALWAYS_EQUAL >::destroy |
( |
ELEMENT_TYPE * |
address | ) |
|
|
inline |
Invoke the ELEMENT_TYPE destructor for the object at the specified address.
template<class TYPE , bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION, bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT, bool PROPAGATE_ON_CONTAINER_SWAP, bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT, bool IS_ALWAYS_EQUAL>
| StdStatefulAllocator< TYPE, PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION, PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT, PROPAGATE_ON_CONTAINER_SWAP, PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT, IS_ALWAYS_EQUAL >::size_type bsltf::StdStatefulAllocator< TYPE, PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION, PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT, PROPAGATE_ON_CONTAINER_SWAP, PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT, IS_ALWAYS_EQUAL >::max_size |
( |
| ) |
const |
|
inline |
Return the maximum number of elements of type TYPE that can be allocated using this allocator in a single call to the allocate method.
- Note
- Note that there is no guarantee that attempts at allocating less elements than the value returned by max_size will not throw. *** DO NOT RELY ON THE CONTINUING PRESENT OF THIS METHOD *** THIS METHOD WILL BE REMOVED ONCE
bslstl::allocator_traits PROPERLY DEDUCES AN IMPLEMENTATION FOR THIS FUNCTION WHEN NOT SUPPLIED BY THE ALLOCATOR DIRECTLY.
template<class TYPE , bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION, bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT, bool PROPAGATE_ON_CONTAINER_SWAP, bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT, bool IS_ALWAYS_EQUAL>
| StdStatefulAllocator< TYPE, PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION, PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT, PROPAGATE_ON_CONTAINER_SWAP, PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT, IS_ALWAYS_EQUAL > bsltf::StdStatefulAllocator< TYPE, PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION, PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT, PROPAGATE_ON_CONTAINER_SWAP, PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT, IS_ALWAYS_EQUAL >::select_on_container_copy_construction |
( |
| ) |
const |
|
inline |
Return a copy of this object if the bool template parameter PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION is true, and a copy of a StdStatefulAllocator object wrapping the default allocator otherwise.