[#BloombergLP-bslma-StdTestAllocator] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslma.adoc[bslma]::StdTestAllocator :relfileprefix: ../../ :mrdocs: An STL‐compatible test allocator that forwards allocation calls to an underlying mechanism object of a type derived from `bslma::TestAllocator`. This class template adheres to the allocator requirements defined in section 20.1.5 [lib.allocator.requirements]of the C++ standard and may be used to instantiate any [container]class template that follows the STL allocator protocol. The allocation mechanism is chosen at run‐time, giving the programmer run‐time control over how a container allocates and frees memory. == Synopsis Declared in `<bslma_stdtestallocator.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class TYPE> class StdTestAllocator; ---- == Types [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslma/StdTestAllocator/rebind.adoc[`rebind`] | This nested `struct` template, parameterized by `ANY_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_TYPE`. Note that this `StdTestAllocator` type is convertible to and from `other` for any type, including `void`. |=== == Type Aliases [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslma/StdTestAllocator/const_pointer.adoc[`const_pointer`] | Alias for a pointer to constant value type. | xref:BloombergLP/bslma/StdTestAllocator/const_reference.adoc[`const_reference`] | Alias for a constant reference to the value type. | xref:BloombergLP/bslma/StdTestAllocator/difference_type.adoc[`difference_type`] | Alias for the allocator difference type. | xref:BloombergLP/bslma/StdTestAllocator/pointer.adoc[`pointer`] | Alias for a pointer to the value type. | xref:BloombergLP/bslma/StdTestAllocator/reference.adoc[`reference`] | Alias for a modifiable reference to the value type. | xref:BloombergLP/bslma/StdTestAllocator/size_type.adoc[`size_type`] | Alias for the allocator size type. | xref:BloombergLP/bslma/StdTestAllocator/value_type.adoc[`value_type`] | Alias for the value type. |=== == 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&`. | 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. The optionally specified `hint` argument is ignored by this test allocator type. The behavior is undefined unless `n <= max_size()`. | xref:BloombergLP/bslma/StdTestAllocator/construct.adoc[`construct`] | Copy‐construct an object of (template parameter) `TYPE` from the specified `val` at the memory address specified by `address`. Do not directly allocate memory. The behavior is undefined unless `address` is not properly aligned for objects of the given `TYPE`. | 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`. The optionally specified `n` argument is ignored by this test allocator type. | xref:BloombergLP/bslma/StdTestAllocator/destroy.adoc[`destroy`] | Call the `TYPE` destructor for the object pointed to by the specified `p`. Do not directly deallocate any memory. | xref:BloombergLP/bslma/StdTestAllocator/max_size.adoc[`max_size`] | Return the maximum number of elements of (template parameter) `TYPE` that can be allocated using this test allocator. Note that there is no guarantee that attempts at allocating fewer elements than the value returned by `max_size` will not throw. | xref:BloombergLP/bslma/StdTestAllocator/mechanism.adoc[`mechanism`] | Return a pointer to the mechanism object to which this proxy forwards allocation and deallocation calls. | xref:BloombergLP/bslma/StdTestAllocator/2conversion-08.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<StdTestAllocator, IsBitwiseCopyable>`] | Declare `StdTestAllocator` as bitwise copyable. | xref:BloombergLP/bslma/StdTestAllocator/2conversion-01.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<StdTestAllocator, IsBitwiseEqualityComparable>`] | Declare `StdTestAllocator` as bitwise equality comparable. | xref:BloombergLP/bslma/StdTestAllocator/2conversion-03.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<StdTestAllocator, IsBitwiseMoveable>`] | Declare `StdTestAllocator` as bitwise moveable. | xref:BloombergLP/bslma/StdTestAllocator/2conversion-04.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<StdTestAllocator, IsStdAllocator>`] | Declare `StdTestAllocator` as an STL‐compatible allocator. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslma/operator_not_eq-0e.adoc[`operator!=`] | Return `true` unless the specified `lhs` and `rhs` are proxies for the same `bslma::TestAllocator` object, in which case return `false`. 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. Note that the two allocators need not be instantiated on the same type in order to compare equal. | xref:BloombergLP/bslma/operator_not_eq-0f.adoc[`operator!=`] | Return `true` unless the specified `lhs` is a proxy for the specified `rhs`, in which case return `false`. | xref:BloombergLP/bslma/operator_eq-07.adoc[`operator==`] | Return `true` if the specified `lhs` and `rhs` are proxies for the same `bslma::TestAllocator` object. | xref:BloombergLP/bslma/operator_eq-0e.adoc[`operator==`] | Return `true` if the specified `lhs` is a proxy for the specified `rhs`, and `false` otherwise. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#