DART 6.13.2
Loading...
Searching...
No Matches
dart::common::StlAllocator< T > Class Template Reference

Wrapper class for MemoryAllocator to be compatible with std::allocator. More...

#include <StlAllocator.hpp>

Inheritance diagram for dart::common::StlAllocator< T >:

Classes

struct  rebind
 

Public Types

using Base = std::allocator< T >
 
using value_type = typename std::allocator_traits< Base >::value_type
 
using size_type = typename std::allocator_traits< Base >::size_type
 
using pointer = typename std::allocator_traits< Base >::pointer
 
using const_pointer = typename std::allocator_traits< Base >::const_pointer
 

Public Member Functions

 StlAllocator (MemoryAllocator &baseAllocator=MemoryAllocator::GetDefault()) noexcept
 Default constructor.
 
 StlAllocator (const StlAllocator &other) throw ()
 Copy constructor.
 
template<class U >
 StlAllocator (const StlAllocator< U > &other) throw ()
 Copy constructor.
 
 ~StlAllocator ()=default
 Destructor.
 
pointer allocate (size_type n, const void *hint=0)
 Allocates n * sizeof(T) bytes of uninitialized storage.
 
void deallocate (pointer pointer, size_type n)
 Deallocates the storage referenced by the pointer p, which must be a pointer obtained by an earlier cal to allocate().
 
void print (std::ostream &os=std::cout, int indent=0) const
 Prints state of the memory allocator.
 

Private Attributes

MemoryAllocatormBaseAllocator
 

Friends

template<typename U >
class StlAllocator
 
template<typename U >
std::ostream & operator<< (std::ostream &os, const StlAllocator< U > &allocator)
 Prints state of the memory allocator.
 

Detailed Description

template<typename T>
class dart::common::StlAllocator< T >

Wrapper class for MemoryAllocator to be compatible with std::allocator.

Member Typedef Documentation

◆ Base

template<typename T >
using dart::common::StlAllocator< T >::Base = std::allocator<T>

◆ const_pointer

template<typename T >
using dart::common::StlAllocator< T >::const_pointer = typename std::allocator_traits<Base>::const_pointer

◆ pointer

template<typename T >
using dart::common::StlAllocator< T >::pointer = typename std::allocator_traits<Base>::pointer

◆ size_type

template<typename T >
using dart::common::StlAllocator< T >::size_type = typename std::allocator_traits<Base>::size_type

◆ value_type

template<typename T >
using dart::common::StlAllocator< T >::value_type = typename std::allocator_traits<Base>::value_type

Constructor & Destructor Documentation

◆ StlAllocator() [1/3]

template<typename T >
dart::common::StlAllocator< T >::StlAllocator ( MemoryAllocator baseAllocator = MemoryAllocator::GetDefault())
explicitnoexcept

Default constructor.

◆ StlAllocator() [2/3]

template<typename T >
dart::common::StlAllocator< T >::StlAllocator ( const StlAllocator< T > &  other)
throw (
)

Copy constructor.

◆ StlAllocator() [3/3]

template<typename T >
template<class U >
dart::common::StlAllocator< T >::StlAllocator ( const StlAllocator< U > &  other)
throw (
)

Copy constructor.

◆ ~StlAllocator()

template<typename T >
dart::common::StlAllocator< T >::~StlAllocator ( )
default

Destructor.

Member Function Documentation

◆ allocate()

template<typename T >
StlAllocator< T >::pointer dart::common::StlAllocator< T >::allocate ( size_type  n,
const void *  hint = 0 
)

Allocates n * sizeof(T) bytes of uninitialized storage.

Parameters
[in]nThe number of objects to allocate sotrage for.
[in]hintPoint to a nearby memory location.
Returns
On success, the pointer to the beginning of newly allocated memory.
On failure, a null pointer

◆ deallocate()

template<typename T >
void dart::common::StlAllocator< T >::deallocate ( pointer  pointer,
size_type  n 
)

Deallocates the storage referenced by the pointer p, which must be a pointer obtained by an earlier cal to allocate().

Parameters
[in]pointerPointer obtained from allocate().
[in]nNumber of objects earlier passed to allocate().

◆ print()

template<typename T >
void dart::common::StlAllocator< T >::print ( std::ostream &  os = std::cout,
int  indent = 0 
) const

Prints state of the memory allocator.

Friends And Related Symbol Documentation

◆ operator<<

template<typename T >
template<typename U >
std::ostream & operator<< ( std::ostream &  os,
const StlAllocator< U > &  allocator 
)
friend

Prints state of the memory allocator.

◆ StlAllocator

template<typename T >
template<typename U >
friend class StlAllocator
friend

Member Data Documentation

◆ mBaseAllocator

template<typename T >
MemoryAllocator& dart::common::StlAllocator< T >::mBaseAllocator
private