[#BloombergLP-bsltf-StdStatefulAllocator]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bsltf.adoc[bsltf]::StdStatefulAllocator
:relfileprefix: ../../
:mrdocs:

Standard&hyphen;compliant test allocator that wraps a distinct allocator state&period;

== Synopsis

Declared in `&lt;bsltf&lowbar;stdstatefulallocator&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class TYPE,
    bool PROPAGATE&lowbar;ON&lowbar;CONTAINER&lowbar;COPY&lowbar;CONSTRUCTION = true,
    bool PROPAGATE&lowbar;ON&lowbar;CONTAINER&lowbar;COPY&lowbar;ASSIGNMENT = true,
    bool PROPAGATE&lowbar;ON&lowbar;CONTAINER&lowbar;SWAP = true,
    bool PROPAGATE&lowbar;ON&lowbar;CONTAINER&lowbar;MOVE&lowbar;ASSIGNMENT = true,
    bool IS&lowbar;ALWAYS&lowbar;EQUAL = false&gt;
class StdStatefulAllocator;
----

== Description

This allocator implements the minimal interface to comply with section 17&period;6&period;3&period;5 (&lsqb;allocator&period;requirements&rsqb;) of the C&plus;&plus;11 standard, while maintaining a distinct object state &hyphen; in this case a wrapped pointer to a `bslma&colon;&colon;Allocator`&period; The template is configurable to control its allocator propagation properties, but does not support the BDE &quot;scoped&quot; allocator model, as scoped allocators should never propagate&period; Instances of this allocator delegate their operations to the wrapped allocator that constitutes its state&period; Note that while we define the various traits used by the C&plus;&plus;11 allocator traits facility, they actually mean very little for this component, as it is the consumer of the allocator&apos;s responsibility to check and apply the traits correctly, typically by using `bsl&colon;&colon;allocator&lowbar;traits` to perform all memory allocation tasks rather than using the allocator directly&period; The `PROPAGATE&lowbar;ON&lowbar;CONTAINER&lowbar;COPY&lowbar;CONSTRUCTION` flag is consumed directly though, in the static member function `select&lowbar;on&lowbar;container&lowbar;copy&lowbar;construction`&period;

== Types

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bsltf/StdStatefulAllocator/rebind.adoc[`rebind`] 
| Nested trait providing an allocator for a different value type&period;
|===


== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bsltf/StdStatefulAllocator/const_pointer.adoc[`const&lowbar;pointer`] 
| Alias for a pointer to `const TYPE`&period;
| xref:BloombergLP/bsltf/StdStatefulAllocator/difference_type.adoc[`difference&lowbar;type`] 
| Alias for `std&colon;&colon;ptrdiff&lowbar;t`&period;
| xref:BloombergLP/bsltf/StdStatefulAllocator/is_always_equal.adoc[`is&lowbar;always&lowbar;equal`] 
| Alias for an `allocator&lowbar;traits` equality trait reflecting the `IS&lowbar;ALWAYS&lowbar;EQUAL` template parameter&period;
| xref:BloombergLP/bsltf/StdStatefulAllocator/pointer.adoc[`pointer`] 
| Alias for a pointer to `TYPE`&period;
| xref:BloombergLP/bsltf/StdStatefulAllocator/propagate_on_container_copy_assignment.adoc[`propagate&lowbar;on&lowbar;container&lowbar;copy&lowbar;assignment`] 
| Alias for an `allocator&lowbar;traits` propagation trait reflecting the `PROPAGATE&lowbar;ON&lowbar;CONTAINER&lowbar;COPY&lowbar;ASSIGNMENT` template parameter&period;
| xref:BloombergLP/bsltf/StdStatefulAllocator/propagate_on_container_move_assignment.adoc[`propagate&lowbar;on&lowbar;container&lowbar;move&lowbar;assignment`] 
| Alias for an `allocator&lowbar;traits` propagation trait reflecting the `PROPAGATE&lowbar;ON&lowbar;CONTAINER&lowbar;MOVE&lowbar;ASSIGNMENT` template parameter&period;
| xref:BloombergLP/bsltf/StdStatefulAllocator/propagate_on_container_swap.adoc[`propagate&lowbar;on&lowbar;container&lowbar;swap`] 
| Alias for an `allocator&lowbar;traits` propagation trait reflecting the `PROPAGATE&lowbar;ON&lowbar;CONTAINER&lowbar;SWAP` template parameter&period;
| xref:BloombergLP/bsltf/StdStatefulAllocator/size_type.adoc[`size&lowbar;type`] 
| Alias for `std&colon;&colon;size&lowbar;t`&period;
| xref:BloombergLP/bsltf/StdStatefulAllocator/value_type.adoc[`value&lowbar;type`] 
| Alias for the allocated `TYPE`&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bsltf/StdStatefulAllocator/2constructor-00.adoc[`StdStatefulAllocator`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bsltf/StdStatefulAllocator/allocate.adoc[`allocate`] 
| Allocate space for the specified number of `TYPE` objects&period;
| xref:BloombergLP/bsltf/StdStatefulAllocator/allocator.adoc[`allocator`] 
| Return the address of the allocator wrapped by this object&period;
| xref:BloombergLP/bsltf/StdStatefulAllocator/construct.adoc[`construct`] 
| Construct an `ELEMENT&lowbar;TYPE` object at the specified address&period;
| xref:BloombergLP/bsltf/StdStatefulAllocator/deallocate.adoc[`deallocate`] 
| Return previously allocated memory to this allocator&period;
| xref:BloombergLP/bsltf/StdStatefulAllocator/destroy.adoc[`destroy`] 
| Invoke the `ELEMENT&lowbar;TYPE` destructor for the object at the specified `address`&period;
| xref:BloombergLP/bsltf/StdStatefulAllocator/max_size.adoc[`max&lowbar;size`] 
| Return the maximum number of `TYPE` elements allocatable in one call&period;
| xref:BloombergLP/bsltf/StdStatefulAllocator/select_on_container_copy_construction.adoc[`select&lowbar;on&lowbar;container&lowbar;copy&lowbar;construction`] 
| Return the allocator to use when copy&hyphen;constructing a container&period;
| xref:BloombergLP/bsltf/StdStatefulAllocator/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;StdStatefulAllocator, IsStdAllocator&gt;`] 
| Declare `StdStatefulAllocator` as a standard allocator&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bsltf/operator_not_eq-0c.adoc[`operator!&equals;`]
| Return whether two allocators wrap different underlying allocators&period;
| xref:BloombergLP/bsltf/operator_eq-04d.adoc[`operator&equals;&equals;`]
| Return whether two allocators wrap the same underlying allocator&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
