[#BloombergLP-bslma-StdTestAllocator]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslma.adoc[bslma]::StdTestAllocator
:relfileprefix: ../../
:mrdocs:

An STL&hyphen;compatible test allocator that forwards allocation calls to an underlying mechanism object of a type derived from `bslma&colon;&colon;TestAllocator`&period; This class template adheres to the allocator requirements defined in section 20&period;1&period;5 &lsqb;lib&period;allocator&period;requirements&rsqb;of the C&plus;&plus; standard and may be used to instantiate any &lsqb;container&rsqb;class template that follows the STL allocator protocol&period; The allocation mechanism is chosen at run&hyphen;time, giving the programmer run&hyphen;time control over how a container allocates and frees memory&period;

== Synopsis

Declared in `&lt;bslma&lowbar;stdtestallocator&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class TYPE&gt;
class StdTestAllocator;
----

== Types

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslma/StdTestAllocator/rebind.adoc[`rebind`] 
| This nested `struct` template, parameterized by `ANY&lowbar;TYPE`, provides a namespace for an `other` type alias, which is a `StdTestAllocator` type following the same template as this one but that allocates elements of `ANY&lowbar;TYPE`&period; Note that this `StdTestAllocator` type is convertible to and from `other` for any type, including `void`&period;
|===


== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslma/StdTestAllocator/const_pointer.adoc[`const&lowbar;pointer`] 
| Alias for a pointer to constant value type&period;
| xref:BloombergLP/bslma/StdTestAllocator/const_reference.adoc[`const&lowbar;reference`] 
| Alias for a constant reference to the value type&period;
| xref:BloombergLP/bslma/StdTestAllocator/difference_type.adoc[`difference&lowbar;type`] 
| Alias for the allocator difference type&period;
| xref:BloombergLP/bslma/StdTestAllocator/pointer.adoc[`pointer`] 
| Alias for a pointer to the value type&period;
| xref:BloombergLP/bslma/StdTestAllocator/reference.adoc[`reference`] 
| Alias for a modifiable reference to the value type&period;
| xref:BloombergLP/bslma/StdTestAllocator/size_type.adoc[`size&lowbar;type`] 
| Alias for the allocator size type&period;
| xref:BloombergLP/bslma/StdTestAllocator/value_type.adoc[`value&lowbar;type`] 
| Alias for the value type&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslma/StdTestAllocator/2constructor-00.adoc[`StdTestAllocator`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bslma/StdTestAllocator/address-02.adoc[`address`] 
| Return the address of the object referred to by the specified `x`, even if the (template parameter) `TYPE` overloads the unary `operator&amp;`&period;
| xref:BloombergLP/bslma/StdTestAllocator/allocate.adoc[`allocate`] 
| Allocate enough (properly aligned) space for the specified `n` objects of (template parameter) `TYPE` by calling `allocate` on the mechanism object&period; The optionally specified `hint` argument is ignored by this test allocator type&period; The behavior is undefined unless `n &lt;&equals; max&lowbar;size()`&period;
| xref:BloombergLP/bslma/StdTestAllocator/construct.adoc[`construct`] 
| Copy&hyphen;construct an object of (template parameter) `TYPE` from the specified `val` at the memory address specified by `address`&period; Do not directly allocate memory&period; The behavior is undefined unless `address` is not properly aligned for objects of the given `TYPE`&period;
| xref:BloombergLP/bslma/StdTestAllocator/deallocate.adoc[`deallocate`] 
| Return memory previously allocated with `allocate` to the underlying mechanism object by calling `deallocate` on the mechanism object with the specified `p`&period; The optionally specified `n` argument is ignored by this test allocator type&period;
| xref:BloombergLP/bslma/StdTestAllocator/destroy.adoc[`destroy`] 
| Call the `TYPE` destructor for the object pointed to by the specified `p`&period; Do not directly deallocate any memory&period;
| xref:BloombergLP/bslma/StdTestAllocator/max_size.adoc[`max&lowbar;size`] 
| Return the maximum number of elements of (template parameter) `TYPE` that can be allocated using this test allocator&period; Note that there is no guarantee that attempts at allocating fewer elements than the value returned by `max&lowbar;size` will not throw&period;
| xref:BloombergLP/bslma/StdTestAllocator/mechanism.adoc[`mechanism`] 
| Return a pointer to the mechanism object to which this proxy forwards allocation and deallocation calls&period;
| xref:BloombergLP/bslma/StdTestAllocator/2conversion-08.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;StdTestAllocator, IsBitwiseCopyable&gt;`] 
| Declare `StdTestAllocator` as bitwise copyable&period;
| xref:BloombergLP/bslma/StdTestAllocator/2conversion-01.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;StdTestAllocator, IsBitwiseEqualityComparable&gt;`] 
| Declare `StdTestAllocator` as bitwise equality comparable&period;
| xref:BloombergLP/bslma/StdTestAllocator/2conversion-03.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;StdTestAllocator, IsBitwiseMoveable&gt;`] 
| Declare `StdTestAllocator` as bitwise moveable&period;
| xref:BloombergLP/bslma/StdTestAllocator/2conversion-04.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;StdTestAllocator, IsStdAllocator&gt;`] 
| Declare `StdTestAllocator` as an STL&hyphen;compatible allocator&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslma/operator_not_eq-0e.adoc[`operator!&equals;`]
| Return `true` unless the specified `lhs` and `rhs` are proxies for the same `bslma&colon;&colon;TestAllocator` object, in which case return `false`&period; This is a practical implementation of the STL requirement that two allocators compare equal if and only if memory allocated from one can be deallocated from the other&period; Note that the two allocators need not be instantiated on the same type in order to compare equal&period;
| xref:BloombergLP/bslma/operator_not_eq-0f.adoc[`operator!&equals;`]
| Return `true` unless the specified `lhs` is a proxy for the specified `rhs`, in which case return `false`&period;
| xref:BloombergLP/bslma/operator_eq-07.adoc[`operator&equals;&equals;`]
| Return `true` if the specified `lhs` and `rhs` are proxies for the same `bslma&colon;&colon;TestAllocator` object&period;
| xref:BloombergLP/bslma/operator_eq-0e.adoc[`operator&equals;&equals;`]
| Return `true` if the specified `lhs` is a proxy for the specified `rhs`, and `false` otherwise&period;
|===


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