allocator_base Class Template Reference
[Memory Library]

#include <stlsoft/memory/allocator_base.hpp>

Inheritance diagram for allocator_base:

malloc_allocator new_allocator null_allocator static_array_1d static_array_2d static_array_3d static_array_4d

List of all members.


Detailed Description

template<typename T, typename A>
class stlsoft::allocator_base< T, A >

STL Allocator base class adaptor, providing much of the boilerplate functionality of an STL-compliant Allocator class.

Parameters:
T The allocator value_type
A The adapted/derived allocator type
This class template abstracts away much of the common boilerplate functionality of allocator classes, requiring that a derived type defines only a simple set of non-static member functions:

See also:
stlsoft::malloc_allocator | stlsoft::new_allocator | stlsoft::null_allocator | comstl::task_allocator | mfcstl::afx_allocator | winstl::global_allocator | winstl::netapi_allocator | winstl::processheap_allocator | winstl::shell_allocator
Remarks:
This uses the SCTP/CRTP (Simulated Compile-time Polymorphism / Curiously Recurring Template Pattern) technique, such that derived classes inherit from parameterisations of the adaptor template which specify their fully derived template-id as the first parameter
Note:
By default, an allocation failure results in a thrown std::bad_alloc. If the compiler does not throwing std::bad_alloc by default, this behaviour can be forced by defining STLSOFT_FORCE_ATORS_THROW_BAD_ALLOC. std::bad_alloc can be suppressed in all circumstances by defining STLSOFT_FORCE_ATORS_RETURN_NULL.

Types

typedef T value_type
 The value type.
typedef allocator_base< T, A > class_type
 The type of the current parameterisation.
typedef value_typepointer
 The pointer type.
typedef value_type const * const_pointer
 The non-mutating (const) pointer type.
typedef value_typereference
 The reference type.
typedef value_type const & const_reference
 The non-mutating (const) reference type.
typedef ss_ptrdiff_t difference_type
 The difference type.
typedef size_t size_type
 The size type.

Public Member Functions

Attributes
size_type max_size () const throw ()
 Returns the maximum number of allocatable entities.
Conversion functions
pointer address (reference x) const throw ()
 Returns the address corresponding to the given reference.
const_pointer address (const_reference x) const throw ()
 Returns the address corresponding to the given non-mutable (const) reference.
Allocation
pointer allocate (size_type n, void const *hint=NULL)
 Allocates a block of memory sufficient to store n elements of type value_type.
char_Charalloc (size_type n)
 A method required by the Dinkumware libraries shipped with older versions of Visual C++.
void deallocate (deallocate_pointer p, size_type n)
 Deallocates a pointer.
void deallocate (deallocate_pointer p)
 Deallocates a pointer.
Object initialisation
void construct (pointer p, value_type const &x)
 In-place constructs an instance of the value_type, with the given value.
void construct (pointer p)
 In-place constructs an instance of the value_type.
void destroy (pointer p) throw ()
 In-place destroys an instance.

Member Typedef Documentation

typedef T value_type

typedef allocator_base<T, A> class_type

The type of the current parameterisation.

Reimplemented in static_array_1d, static_array_2d, static_array_3d, static_array_4d, malloc_allocator, new_allocator, and null_allocator.

typedef value_type* pointer

typedef value_type const* const_pointer

The non-mutating (const) pointer type.

Reimplemented in static_array_1d, static_array_2d, static_array_3d, static_array_4d, malloc_allocator, new_allocator, and null_allocator.

typedef value_type const& const_reference

The non-mutating (const) reference type.

Reimplemented in static_array_1d, static_array_2d, static_array_3d, static_array_4d, malloc_allocator, new_allocator, and null_allocator.

typedef size_t size_type


Member Function Documentation

size_type max_size (  )  const throw () [inline]

Returns the maximum number of allocatable entities.

pointer address ( reference  x  )  const throw () [inline]

Returns the address corresponding to the given reference.

Parameters:
x A reference to a value_type instance whose address will be calculated

const_pointer address ( const_reference  x  )  const throw () [inline]

Returns the address corresponding to the given non-mutable (const) reference.

Parameters:
x A non-mutable (const) reference to a value_type instance whose address will be calculated

pointer allocate ( size_type  n,
void const *  hint = NULL 
) [inline]

Allocates a block of memory sufficient to store n elements of type value_type.

Parameters:
n The number of elements to allocate
hint A hint to enhance localisation
Returns:
The allocated block, or the null pointer (if the allocation fails and the translator does not support throwing exceptions upon memory exhaustion)

Referenced by allocator_base< T, stlsoft::new_allocator< T > >::_Charalloc().

char* _Charalloc ( size_type  n  )  [inline]

A method required by the Dinkumware libraries shipped with older versions of Visual C++.

The method is functionally identical to static_cast<char*>(allocate(n, NULL))

Remarks:
This method is only defined when the symbol STLSOFT_CF_ALLOCATOR_CHARALLOC_METHOD is defined.

void deallocate ( deallocate_pointer  p,
size_type  n 
) [inline]

Deallocates a pointer.

Parameters:
p The memory block to deallocate
n The number of blocks to deallocate

void deallocate ( deallocate_pointer  p  )  [inline]

Deallocates a pointer.

Parameters:
p The memory block to deallocate

void construct ( pointer  p,
value_type const &  x 
) [inline]

In-place constructs an instance of the value_type, with the given value.

Parameters:
p The location in which to construct the instance
x The value with which to copy construct the instance

void construct ( pointer  p  )  [inline]

In-place constructs an instance of the value_type.

Parameters:
p The location in which to construct the instance

void destroy ( pointer  p  )  throw () [inline]

In-place destroys an instance.

Parameters:
p The instance whose destructor is to be called


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

Generated on Thu Jun 10 08:58:51 2010 for STLSoft by  doxygen 1.5.6