AGX Dynamics  2.37.2.0
agx::StackAllocator< T, N > Class Template Reference

The StackAllocator class is designed to be used with the STL vector class. More...

#include <StackAllocator.h>

Public Types

typedef const T * const_pointer
 
typedef const T & const_reference
 
typedef std::ptrdiff_t difference_type
 
typedef T * pointer
 
typedef T & reference
 
typedef std::size_t size_type
 
typedef T value_type
 

Public Member Functions

 StackAllocator () throw ()
 
 ~StackAllocator () throw ()
 
pointer address (reference value) const
 
const_pointer address (const_reference value) const
 
pointer allocate (size_type num, const void *=0)
 
void construct (pointer p, const T &value)
 
void deallocate (pointer p, size_type num)
 
void destroy (pointer p)
 
size_type max_size () const throw ()
 

Detailed Description

template<class T, int N>
class agx::StackAllocator< T, N >

The StackAllocator class is designed to be used with the STL vector class.

It allocates the required amount of space directly on the stack where an STL container is declared. Because the STL template for the allocator must have a single argument, this template must be specialized to the desired value of the template argument N before being used in an STL container declaration. The source code for the present class is adapted from the standard definition of the allocator class in STL, as in the book "The C++ Standard Library: A Tutorial and Reference" by Nicolai M. Josuttis, Addison Wesley,

  1. The main difference here is that all calls to the method allocate() return a pointer to m_data.

The explicit assumption made here is that the STL container requires only space for N objects and that any other overhead for begin, end, and capacity pointers are allocated in the stack of the STL class itself. In particular, this allocator cannot work with std::list at this time.

In addition, the rebind utility is not provided and neither is the copy constructor.

Definition at line 54 of file StackAllocator.h.

Member Typedef Documentation

◆ const_pointer

template<class T , int N>
typedef const T* agx::StackAllocator< T, N >::const_pointer

Definition at line 61 of file StackAllocator.h.

◆ const_reference

template<class T , int N>
typedef const T& agx::StackAllocator< T, N >::const_reference

Definition at line 63 of file StackAllocator.h.

◆ difference_type

template<class T , int N>
typedef std::ptrdiff_t agx::StackAllocator< T, N >::difference_type

Definition at line 65 of file StackAllocator.h.

◆ pointer

template<class T , int N>
typedef T* agx::StackAllocator< T, N >::pointer

Definition at line 60 of file StackAllocator.h.

◆ reference

template<class T , int N>
typedef T& agx::StackAllocator< T, N >::reference

Definition at line 62 of file StackAllocator.h.

◆ size_type

template<class T , int N>
typedef std::size_t agx::StackAllocator< T, N >::size_type

Definition at line 64 of file StackAllocator.h.

◆ value_type

template<class T , int N>
typedef T agx::StackAllocator< T, N >::value_type

Definition at line 59 of file StackAllocator.h.

Constructor & Destructor Documentation

◆ StackAllocator()

template<class T , int N>
agx::StackAllocator< T, N >::StackAllocator ( )
throw (
)
inline

Definition at line 78 of file StackAllocator.h.

◆ ~StackAllocator()

template<class T , int N>
agx::StackAllocator< T, N >::~StackAllocator ( )
throw (
)
inline

Definition at line 81 of file StackAllocator.h.

Member Function Documentation

◆ address() [1/2]

template<class T , int N>
pointer agx::StackAllocator< T, N >::address ( reference  value) const
inline

Definition at line 68 of file StackAllocator.h.

◆ address() [2/2]

template<class T , int N>
const_pointer agx::StackAllocator< T, N >::address ( const_reference  value) const
inline

Definition at line 71 of file StackAllocator.h.

◆ allocate()

template<class T , int N>
pointer agx::StackAllocator< T, N >::allocate ( size_type  num,
const void *  = 0 
)
inline

Definition at line 90 of file StackAllocator.h.

◆ construct()

template<class T , int N>
void agx::StackAllocator< T, N >::construct ( pointer  p,
const T &  value 
)
inline

Definition at line 95 of file StackAllocator.h.

◆ deallocate()

template<class T , int N>
void agx::StackAllocator< T, N >::deallocate ( pointer  p,
size_type  num 
)
inline

Definition at line 107 of file StackAllocator.h.

◆ destroy()

template<class T , int N>
void agx::StackAllocator< T, N >::destroy ( pointer  p)
inline

Definition at line 101 of file StackAllocator.h.

◆ max_size()

template<class T , int N>
size_type agx::StackAllocator< T, N >::max_size ( ) const
throw (
)
inline

Definition at line 85 of file StackAllocator.h.


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