BloombergLP::bsltf::StdStatefulAllocator

Standard-compliant test allocator that wraps a distinct allocator state.

Synopsis

Declared in <bsltf_stdstatefulallocator.h>

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 StdStatefulAllocator;

Description

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 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.

Types

NameDescription
rebind Nested trait providing an allocator for a different value type.

Type Aliases

NameDescription
const_pointer Alias for a pointer to const TYPE.
difference_type Alias for std::ptrdiff_t.
is_always_equal Alias for an allocator_traits equality trait reflecting the IS_ALWAYS_EQUAL template parameter.
pointer Alias for a pointer to TYPE.
propagate_on_container_copy_assignment Alias for an allocator_traits propagation trait reflecting the PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT template parameter.
propagate_on_container_move_assignment Alias for an allocator_traits propagation trait reflecting the PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT template parameter.
propagate_on_container_swap Alias for an allocator_traits propagation trait reflecting the PROPAGATE_ON_CONTAINER_SWAP template parameter.
size_type Alias for std::size_t.
value_type Alias for the allocated TYPE.

Member Functions

NameDescription
StdStatefulAllocator [constructor]Constructors
allocate Allocate space for the specified number of TYPE objects.
allocator Return the address of the allocator wrapped by this object.
construct Construct an ELEMENT_TYPE object at the specified address.
deallocate Return previously allocated memory to this allocator.
destroy Invoke the ELEMENT_TYPE destructor for the object at the specified address.
max_size Return the maximum number of TYPE elements allocatable in one call.
select_on_container_copy_construction Return the allocator to use when copy-constructing a container.
operator BloombergLP::bslmf::NestedTraitDeclaration<StdStatefulAllocator, IsStdAllocator> Declare StdStatefulAllocator as a standard allocator.

Non-Member Functions

NameDescription
operator!=Return whether two allocators wrap different underlying allocators.
operator==Return whether two allocators wrap the same underlying allocator.