Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::base::StlAllocator< T > Class Template Reference

StlAllocator is derived std::allocator class that allows an Ion Allocator to be used for STL containers. More...

#include "stlallocator.h"

Inheritance diagram for ion::base::StlAllocator< T >:
Collaboration diagram for ion::base::StlAllocator< T >:

Classes

struct  rebind
 

Public Types

typedef std::allocator< T >
::pointer 
Pointer
 
typedef std::allocator< T >
::const_pointer 
ConstPointer
 
typedef std::allocator< T >
::size_type 
SizeType
 
typedef std::true_type propagate_on_container_move_assignment
 These allocator traits affect the behavior of containers such as AllocVector. More...
 
typedef std::true_type propagate_on_container_swap
 

Public Member Functions

 StlAllocator (const AllocatorPtr &allocator)
 
template<typename U >
 StlAllocator (const StlAllocator< U > &a)
 This copy constructor cannot be explicit because older versions of STL seem to implicitly cast between allocators of different types. More...
 
const AllocatorPtrGetAllocator () const
 Returns the Allocator used by this. More...
 
Pointer allocate (SizeType n, ConstPointer hint=0)
 
void deallocate (Pointer p, SizeType n)
 
void construct (Pointer p, const T &val)
 Replace the construct() functions so that we can pass an Allocator to Allocatable types. More...
 
template<typename... Args>
void construct (Pointer p, Args &&...args)
 
template<class U , class... Args>
void construct (U *p, Args &&...args)
 

Public Attributes

T elements
 STL member. More...
 

Friends

template<typename U >
class StlAllocator
 

Detailed Description

template<typename T>
class ion::base::StlAllocator< T >

StlAllocator is derived std::allocator class that allows an Ion Allocator to be used for STL containers.

There are derived container classes (such as AllocVector and AllocMap) that make it easier to use this allocator.

Definition at line 35 of file stlallocator.h.

Member Typedef Documentation

template<typename T>
typedef std::allocator<T>::const_pointer ion::base::StlAllocator< T >::ConstPointer

Definition at line 38 of file stlallocator.h.

template<typename T>
typedef std::allocator<T>::pointer ion::base::StlAllocator< T >::Pointer

Definition at line 37 of file stlallocator.h.

template<typename T>
typedef std::true_type ion::base::StlAllocator< T >::propagate_on_container_move_assignment

These allocator traits affect the behavior of containers such as AllocVector.

During an assignment or swap, the StlAllocators will be swapped along with the container's memory.

Definition at line 44 of file stlallocator.h.

template<typename T>
typedef std::true_type ion::base::StlAllocator< T >::propagate_on_container_swap

Definition at line 45 of file stlallocator.h.

template<typename T>
typedef std::allocator<T>::size_type ion::base::StlAllocator< T >::SizeType

Definition at line 39 of file stlallocator.h.

Constructor & Destructor Documentation

template<typename T>
ion::base::StlAllocator< T >::StlAllocator ( const AllocatorPtr allocator)
inlineexplicit

Definition at line 47 of file stlallocator.h.

template<typename T>
template<typename U >
ion::base::StlAllocator< T >::StlAllocator ( const StlAllocator< U > &  a)
inline

This copy constructor cannot be explicit because older versions of STL seem to implicitly cast between allocators of different types.

Definition at line 51 of file stlallocator.h.

Member Function Documentation

template<typename T>
Pointer ion::base::StlAllocator< T >::allocate ( SizeType  n,
ConstPointer  hint = 0 
)
inline
template<typename T>
void ion::base::StlAllocator< T >::construct ( Pointer  p,
const T val 
)
inline

Replace the construct() functions so that we can pass an Allocator to Allocatable types.

The construct() functions inform the allocation system that there is a placement new allocation that might be an Allocatable. If the constructed type is trivially destructible, then construct() is forwarded to std::allocator, which just calls placement new(). Any non-trivially-destructible type that is default, copy, or move constructed, and thus might contain an Allocatable, will receive this container's Allocator.

Definition at line 73 of file stlallocator.h.

References type, and value.

template<typename T>
template<typename... Args>
void ion::base::StlAllocator< T >::construct ( Pointer  p,
Args &&...  args 
)
inline

Definition at line 84 of file stlallocator.h.

References type, and value.

template<typename T>
template<class U , class... Args>
void ion::base::StlAllocator< T >::construct ( U *  p,
Args &&...  args 
)
inline

Definition at line 95 of file stlallocator.h.

References type, and value.

template<typename T>
void ion::base::StlAllocator< T >::deallocate ( Pointer  p,
SizeType  n 
)
inline
template<typename T>
const AllocatorPtr& ion::base::StlAllocator< T >::GetAllocator ( ) const
inline

Returns the Allocator used by this.

Definition at line 54 of file stlallocator.h.

Referenced by ion::base::operator!=(), and ion::base::operator==().

Friends And Related Function Documentation

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

Definition at line 150 of file stlallocator.h.

Member Data Documentation

T std::allocator< T >::elements
inherited

STL member.


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