#include <bslma_stdtestallocator.h>
List of all members.
Classes |
struct | rebind |
Public Types |
typedef std::size_t | size_type |
typedef std::ptrdiff_t | difference_type |
typedef TYPE * | pointer |
typedef const TYPE * | const_pointer |
typedef bsl::conditional
< bsl::is_void< TYPE >::value,
void, TYPE & >::type | reference |
typedef bsl::conditional
< bsl::is_void< TYPE >::value,
void, const TYPE & >::type | const_reference |
typedef TYPE | value_type |
Public Member Functions |
| BSLMF_NESTED_TRAIT_DECLARATION (StdTestAllocator, bsl::is_trivially_copyable) |
| BSLMF_NESTED_TRAIT_DECLARATION (StdTestAllocator, bslmf::IsBitwiseMoveable) |
| BSLMF_NESTED_TRAIT_DECLARATION (StdTestAllocator, bslmf::IsBitwiseEqualityComparable) |
| StdTestAllocator () |
| StdTestAllocator (Allocator *mechanism) |
| StdTestAllocator (const StdTestAllocator &original) |
template<class ANY_TYPE > |
| StdTestAllocator (const StdTestAllocator< ANY_TYPE > &rhs) |
| ~StdTestAllocator () |
StdTestAllocator & | operator= (const StdTestAllocator &rhs) |
pointer | allocate (size_type n, const void *hint=0) |
void | deallocate (pointer p, size_type n=1) |
template<class ELEMENT_TYPE > |
void | construct (ELEMENT_TYPE *address, const TYPE &val) |
template<class ELEMENT_TYPE > |
void | destroy (ELEMENT_TYPE *address) |
pointer | address (reference x) const |
const_pointer | address (const_reference x) const |
size_type | max_size () const |
TestAllocator * | mechanism () const |
Detailed Description
template<class TYPE>
class bslma::StdTestAllocator< TYPE >
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.
See Component bslma_stdtestallocator
Member Typedef Documentation
Constructor & Destructor Documentation
TBD: fix comment to mention that the default allocator has to be a test allocator. Create a proxy object which will forward allocation calls to the object pointed to by bslma::Default::defaultAllocator()
. Postcondition:
IMPLICIT: TBD: fix comment to mention that mechanism
has to be a test allocator. Convert a bslma::Allocator
pointer to an test allocator object which forwards allocation calls to the object pointed to by the specified mechanism
. If mechanism
is 0, then the currently installed default allocator is used instead. Postcondition: 0 == mechanism || this->mechanism() == mechanism
.
Create a proxy object using the same mechanism as the specified original
. Postcondition: this->mechanism() == rhs.mechanism()
.
template<class TYPE>
template<class ANY_TYPE >
Create a proxy object sharing the same mechanism object as the specified rhs
. The newly constructed test allocator will compare equal to rhs
, even though they are instantiated on different types. Postcondition: this->mechanism() == rhs.mechanism()
.
Destroy this object. Note that this does not delete the object pointed to by mechanism()
. Also note that this method's definition is compiler generated.
Member Function Documentation
Declare nested type traits for this class.
Assign to this object the value of the specified rhs
. Postcondition: this->mechanism() == rhs->mechanism()
. Note that this does not delete the object pointed to by the previous value of mechanism()
. Also note that this method's definition is compiler generated.
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()
.
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.
template<class TYPE>
template<class ELEMENT_TYPE >
Copy-construct an object of (template parameter) TYPE
from the specified val
at the memory address specified by p
. Do not directly allocate memory. The behavior is undefined unless p
is not properly aligned for objects of the given TYPE
.
template<class TYPE>
template<class ELEMENT_TYPE >
Call the TYPE
destructor for the object pointed to by the specified p
. Do not directly deallocate any memory.
Return the address of the object referred to by the specified x
, even if the (template parameter) TYPE
overloads the unary operator&
.
Return the address of the object referred to by the specified x
, even if the (template parameter) TYPE
overloads the unary operator&
.
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.
Return a pointer to the mechanism object to which this proxy forwards allocation and deallocation calls.
The documentation for this class was generated from the following file: