GCS  0.2.3
Data Structures | Public Types | Public Member Functions
gu::ReservedAllocator< T, reserved, diagnostic > Class Template Reference

#include <gu_reserved_container.hpp>

Data Structures

struct  rebind
 

Public Types

typedef
chromium::AlignedBuffer< T,
reserved > 
Buffer
 
typedef T * pointer
 
typedef const T * const_pointer
 
typedef T & reference
 
typedef const T & const_reference
 
typedef T value_type
 
typedef size_t size_type
 
typedef ptrdiff_t difference_type
 

Public Member Functions

T * address (T &t) const
 
const T * address (const T &t) const
 
size_type max_size () const
 
void construct (T *const p, const T &t) const
 
void destroy (T *const p) const
 
bool operator== (const ReservedAllocator &other) const
 
bool operator!= (const ReservedAllocator &other) const
 
 ReservedAllocator (Buffer &buf, size_type n=0)
 
 ReservedAllocator (const ReservedAllocator &other)
 
template<typename U , size_type c, bool d>
 ReservedAllocator (const ReservedAllocator< U, c, d > &)
 
T * allocate (size_type const n, void *hint=NULL)
 
void deallocate (T *const p, size_type const n)
 
size_type used () const
 

Detailed Description

template<typename T, int reserved, bool diagnostic = false>
class gu::ReservedAllocator< T, reserved, diagnostic >

ReservedAllocator is an allocator for STL containers that can use a prealocated buffer (supplied at construction time) for initial container storage allocation. If the number of elements exceeds buffer capacity, it overflows to heap.

Unlike the Chromium code, this does not derive from std::allocator, but implements the whole thing.

NOTE1: container must support reserve() method.

NOTE2: it won't work with containers that require allocator to have default constructor, like std::basic_string


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