JASSv2
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
JASS::allocator_cpp< TYPE > Class Template Reference

C++ allocator based on the C allocator. More...

#include <allocator_cpp.h>

Collaboration diagram for JASS::allocator_cpp< TYPE >:
Collaboration graph
[legend]

Public Types

using value_type = TYPE
 This is an allocator for objects of type allocator_cpp::value_type.
 

Public Member Functions

 allocator_cpp (allocator &pool)
 Default constructor. More...
 
template<class OTHER_TYPE >
 allocator_cpp (const allocator_cpp< OTHER_TYPE > &other)
 Copy constructor. More...
 
template<class OTHER_TYPE >
bool operator== (const allocator_cpp< OTHER_TYPE > &that) const
 Compare for equality two objects of this class type. More...
 
template<class OTHER_TYPE >
bool operator!= (const allocator_cpp< OTHER_TYPE > &that) const
 Compare for inequlity two objects of this class type. More...
 
TYPE * allocate (const size_t number)
 Allocate space for number of objects of this type. More...
 
void deallocate (TYPE *const pointer, size_t number) const
 Dealocate previously allocated space (not). This method does nothing but is required for a C++11 allocator. More...
 

Static Public Member Functions

static void unittest (void)
 Unit test this class.
 

Public Attributes

allocatorpool
 This is the memory pool from which this C++ allocator allocated.
 

Detailed Description

template<class TYPE>
class JASS::allocator_cpp< TYPE >

C++ allocator based on the C allocator.

Constructor & Destructor Documentation

◆ allocator_cpp() [1/2]

template<class TYPE>
JASS::allocator_cpp< TYPE >::allocator_cpp ( allocator pool)
inline

Default constructor.

Parameters
pool[in] A reference to C style allocator.

◆ allocator_cpp() [2/2]

template<class TYPE>
template<class OTHER_TYPE >
JASS::allocator_cpp< TYPE >::allocator_cpp ( const allocator_cpp< OTHER_TYPE > &  other)
inline

Copy constructor.

Parameters
other[in] the object to copy

Member Function Documentation

◆ allocate()

template<class TYPE>
TYPE* JASS::allocator_cpp< TYPE >::allocate ( const size_t  number)
inline

Allocate space for number of objects of this type.

Parameters
number[in] The number of objects of this type to create space for.
Returns
Pointer to enough memory to store number of objects, else throw an exception.

◆ deallocate()

template<class TYPE>
void JASS::allocator_cpp< TYPE >::deallocate ( TYPE *const  pointer,
size_t  number 
) const
inline

Dealocate previously allocated space (not). This method does nothing but is required for a C++11 allocator.

This method does nothing because this class allocates from a pool allocator which manages all the deallocation itself.

Parameters
pointer[in] A pointer to memory previously allocated by this allocator and to be released.
number[in] The number of objects of this type that were allocated on the call to allocate.

◆ operator!=()

template<class TYPE>
template<class OTHER_TYPE >
bool JASS::allocator_cpp< TYPE >::operator!= ( const allocator_cpp< OTHER_TYPE > &  that) const
inline

Compare for inequlity two objects of this class type.

Parameters
that[in] The object to compare to.
Returns
True if this != that, else false.

◆ operator==()

template<class TYPE>
template<class OTHER_TYPE >
bool JASS::allocator_cpp< TYPE >::operator== ( const allocator_cpp< OTHER_TYPE > &  that) const
inline

Compare for equality two objects of this class type.

Parameters
that[in] The object to compare to.
Returns
True if this == that, else false.

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