BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslma::StdTestAllocator< TYPE > Class Template Reference

#include <bslma_stdtestallocator.h>

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, constTYPE & >::type const_reference
 
typedef TYPE value_type
 

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (StdTestAllocator, bslma::IsStdAllocator)
 
 BSLMF_NESTED_TRAIT_DECLARATION (StdTestAllocator, bslmf::IsBitwiseCopyable)
 
 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 ()
 
StdTestAllocatoroperator= (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
 
TestAllocatormechanism () 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 bslma_stdtestallocator

Member Typedef Documentation

◆ const_pointer

template<class TYPE >
typedef const TYPE* bslma::StdTestAllocator< TYPE >::const_pointer

◆ const_reference

template<class TYPE >
typedef bsl::conditional<bsl::is_void<TYPE>::value,void,constTYPE&>::type bslma::StdTestAllocator< TYPE >::const_reference

◆ difference_type

template<class TYPE >
typedef std::ptrdiff_t bslma::StdTestAllocator< TYPE >::difference_type

◆ pointer

template<class TYPE >
typedef TYPE* bslma::StdTestAllocator< TYPE >::pointer

◆ reference

template<class TYPE >
typedef bsl::conditional<bsl::is_void<TYPE>::value,void,TYPE&>::type bslma::StdTestAllocator< TYPE >::reference

◆ size_type

template<class TYPE >
typedef std::size_t bslma::StdTestAllocator< TYPE >::size_type

◆ value_type

template<class TYPE >
typedef TYPE bslma::StdTestAllocator< TYPE >::value_type

Constructor & Destructor Documentation

◆ StdTestAllocator() [1/4]

template<class TYPE >
bslma::StdTestAllocator< TYPE >::StdTestAllocator ( )
inline

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:

TestAllocator * mechanism() const
Definition bslma_stdtestallocator.h:289
static Allocator * defaultAllocator()
Definition bslma_default.h:889

◆ StdTestAllocator() [2/4]

template<class TYPE >
bslma::StdTestAllocator< TYPE >::StdTestAllocator ( Allocator mechanism)
inline

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.

◆ StdTestAllocator() [3/4]

template<class TYPE >
bslma::StdTestAllocator< TYPE >::StdTestAllocator ( const StdTestAllocator< TYPE > &  original)
inline

Create a proxy object using the same mechanism as the specified original. Postcondition: this->mechanism() == rhs.mechanism().

◆ StdTestAllocator() [4/4]

template<class TYPE >
template<class ANY_TYPE >
bslma::StdTestAllocator< TYPE >::StdTestAllocator ( const StdTestAllocator< ANY_TYPE > &  rhs)
inline

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

◆ ~StdTestAllocator()

template<class TYPE >
bslma::StdTestAllocator< TYPE >::~StdTestAllocator ( )

Member Function Documentation

◆ address() [1/2]

template<class TYPE >
const_pointer bslma::StdTestAllocator< TYPE >::address ( const_reference  x) const

Return the address of the object referred to by the specified x, even if the (template parameter) TYPE overloads the unary operator&.

◆ address() [2/2]

template<class TYPE >
StdTestAllocator< TYPE >::pointer bslma::StdTestAllocator< TYPE >::address ( reference  x) const
inline

Return the address of the object referred to by the specified x, even if the (template parameter) TYPE overloads the unary operator&.

◆ allocate()

template<class TYPE >
StdTestAllocator< TYPE >::pointer bslma::StdTestAllocator< TYPE >::allocate ( typename StdTestAllocator< TYPE >::size_type  n,
const void *  hint = 0 
)
inline

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

◆ BSLMF_NESTED_TRAIT_DECLARATION() [1/4]

template<class TYPE >
bslma::StdTestAllocator< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION ( StdTestAllocator< TYPE >  ,
bslma::IsStdAllocator   
)

◆ BSLMF_NESTED_TRAIT_DECLARATION() [2/4]

template<class TYPE >
bslma::StdTestAllocator< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION ( StdTestAllocator< TYPE >  ,
bslmf::IsBitwiseCopyable   
)

◆ BSLMF_NESTED_TRAIT_DECLARATION() [3/4]

template<class TYPE >
bslma::StdTestAllocator< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION ( StdTestAllocator< TYPE >  ,
bslmf::IsBitwiseEqualityComparable   
)

◆ BSLMF_NESTED_TRAIT_DECLARATION() [4/4]

template<class TYPE >
bslma::StdTestAllocator< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION ( StdTestAllocator< TYPE >  ,
bslmf::IsBitwiseMoveable   
)

◆ construct()

template<class TYPE >
template<class ELEMENT_TYPE >
void bslma::StdTestAllocator< TYPE >::construct ( ELEMENT_TYPE *  address,
const TYPE &  val 
)
inline

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.

◆ deallocate()

template<class TYPE >
void bslma::StdTestAllocator< TYPE >::deallocate ( typename StdTestAllocator< TYPE >::pointer  p,
typename StdTestAllocator< TYPE >::size_type  n = 1 
)
inline

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.

◆ destroy()

template<class TYPE >
template<class ELEMENT_TYPE >
void bslma::StdTestAllocator< TYPE >::destroy ( ELEMENT_TYPE *  address)
inline

Call the TYPE destructor for the object pointed to by the specified p. Do not directly deallocate any memory.

◆ max_size()

template<class TYPE >
StdTestAllocator< TYPE >::size_type bslma::StdTestAllocator< TYPE >::max_size ( ) const
inline

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.

◆ mechanism()

template<class TYPE >
TestAllocator * bslma::StdTestAllocator< TYPE >::mechanism ( ) const
inline

Return a pointer to the mechanism object to which this proxy forwards allocation and deallocation calls.

◆ operator=()

template<class TYPE >
StdTestAllocator & bslma::StdTestAllocator< TYPE >::operator= ( const StdTestAllocator< TYPE > &  rhs)

The documentation for this class was generated from the following file: