ders::stl_allocator< T > Class Template Reference

STL-compatible allocator that uses mem_pool object for memory management. More...

#include <stl_alloc.hpp>

List of all members.

Public Types

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

Public Member Functions

 stl_allocator ()
 stl_allocator (mem_pool &m)
template<class U>
 stl_allocator (const stl_allocator< U > &sa)
pointer address (reference x) const
const_pointer address (const_reference x) const
pointer allocate (size_type n, std::allocator< void >::const_pointer=0)
void deallocate (pointer p, size_type n)
size_type max_size () const throw ()
void construct (pointer p, const T &val)
void destroy (pointer p)
mem_poolpool () const

Classes

struct  rebind
 typedef template required by STL More...


Detailed Description

template<class T>
class ders::stl_allocator< T >

STL-compatible allocator that uses mem_pool object for memory management.

Definition at line 27 of file stl_alloc.hpp.


Member Typedef Documentation

template<class T>
typedef size_t ders::stl_allocator< T >::size_type

Definition at line 31 of file stl_alloc.hpp.

template<class T>
typedef ptrdiff_t ders::stl_allocator< T >::difference_type

Definition at line 32 of file stl_alloc.hpp.

template<class T>
typedef T* ders::stl_allocator< T >::pointer

Definition at line 33 of file stl_alloc.hpp.

template<class T>
typedef const T* ders::stl_allocator< T >::const_pointer

Definition at line 34 of file stl_alloc.hpp.

template<class T>
typedef T& ders::stl_allocator< T >::reference

Definition at line 35 of file stl_alloc.hpp.

template<class T>
typedef const T& ders::stl_allocator< T >::const_reference

Definition at line 36 of file stl_alloc.hpp.

template<class T>
typedef T ders::stl_allocator< T >::value_type

Definition at line 37 of file stl_alloc.hpp.


Constructor & Destructor Documentation

template<class T>
ders::stl_allocator< T >::stl_allocator (  ) 

template<class T>
ders::stl_allocator< T >::stl_allocator ( mem_pool m  )  [inline, explicit]

Definition at line 43 of file stl_alloc.hpp.

00043 : mp(m) {}

template<class T>
template<class U>
ders::stl_allocator< T >::stl_allocator ( const stl_allocator< U > &  sa  )  [inline]

Definition at line 44 of file stl_alloc.hpp.

00044                                                                   :
00045         mp(sa.pool()) {}


Member Function Documentation

template<class T>
pointer ders::stl_allocator< T >::address ( reference  x  )  const [inline]

Definition at line 47 of file stl_alloc.hpp.

00047 { return &x; }

template<class T>
const_pointer ders::stl_allocator< T >::address ( const_reference  x  )  const [inline]

Definition at line 48 of file stl_alloc.hpp.

00048 { return &x; }

template<class T>
stl_allocator< T >::pointer ders::stl_allocator< T >::allocate ( size_type  n,
std::allocator< void >::const_pointer  = 0 
) [inline]

Definition at line 59 of file stl_alloc.hpp.

00061 { return (n!=0) ? static_cast<pointer>(mp.allocate(n*sizeof(T))) : 0; }

template<class T>
void ders::stl_allocator< T >::deallocate ( pointer  p,
size_type  n 
) [inline]

Definition at line 64 of file stl_alloc.hpp.

00065 { if (n!=0) mp.deallocate(p, n*sizeof(T)); }

template<class T>
size_type ders::stl_allocator< T >::max_size (  )  const throw () [inline]

Definition at line 51 of file stl_alloc.hpp.

00051 { return size_t(-1)/sizeof(T); }

template<class T>
void ders::stl_allocator< T >::construct ( pointer  p,
const T &  val 
) [inline]

Definition at line 52 of file stl_alloc.hpp.

00052 { new(p) T(val); }

template<class T>
void ders::stl_allocator< T >::destroy ( pointer  p  )  [inline]

Definition at line 53 of file stl_alloc.hpp.

00053 { p->~T(); }

template<class T>
mem_pool& ders::stl_allocator< T >::pool (  )  const [inline]

Definition at line 55 of file stl_alloc.hpp.

00055 { return mp; }


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

Generated on Tue Dec 8 11:35:33 2009 for derslib by  doxygen 1.5.5