CppCommon
1.0.4.1
C++ Common Library
|
Memory allocator class. More...
#include <allocator.h>
Classes | |
struct | rebind |
Rebind allocator. More... | |
Public Types | |
typedef T | value_type |
Element type. More... | |
typedef T * | pointer |
Pointer to element. More... | |
typedef T & | reference |
Reference to element. More... | |
typedef const T * | const_pointer |
Pointer to constant element. More... | |
typedef const T & | const_reference |
Reference to constant element. More... | |
typedef size_t | size_type |
Quantities of elements. More... | |
typedef ptrdiff_t | difference_type |
Difference between two pointers. More... | |
Public Member Functions | |
Allocator (TMemoryManager &manager) noexcept | |
Initialize allocator with a given memory manager. More... | |
template<typename U > | |
Allocator (const Allocator< U, TMemoryManager, nothrow > &alloc) noexcept | |
Allocator (const Allocator &alloc) noexcept | |
Allocator (Allocator &&) noexcept=default | |
~Allocator () noexcept=default | |
template<typename U > | |
Allocator & | operator= (const Allocator< U, TMemoryManager, nothrow > &alloc) noexcept |
Allocator & | operator= (const Allocator &alloc) noexcept |
Allocator & | operator= (Allocator &&) noexcept=default |
pointer | address (reference x) const noexcept |
Get the address of the given reference. More... | |
const_pointer | address (const_reference x) const noexcept |
Get the constant address of the given constant reference. More... | |
size_type | max_size () const noexcept |
Get the maximum number of elements, that could potentially be allocated by the allocator. More... | |
pointer | allocate (size_type num, const void *hint=0) |
Allocate a block of storage suitable to contain the given count of elements. More... | |
void | deallocate (pointer ptr, size_type num) |
Release a block of storage previously allocated. More... | |
void | reset () |
Reset the allocator. More... | |
template<typename U , class... Args> | |
void | construct (U *ptr, Args &&... args) |
Constructs an element object on the given location pointer. More... | |
template<typename U > | |
void | destroy (U *ptr) |
Destroys in-place the object pointed by the given location pointer. More... | |
template<class... Args> | |
T * | Create (Args &&... args) |
Create a single element object. More... | |
void | Release (T *ptr) |
Release a single element object. More... | |
template<class... Args> | |
T * | CreateArray (size_t length, Args &&... args) |
Create an array of element objects. More... | |
void | ReleaseArray (T *ptr) |
Release an array of element objects. More... | |
Friends | |
template<typename U , class UMemoryManager , bool flag> | |
class | Allocator |
Memory allocator class.
Memory allocator implements standard allocator interface and wraps the memory manager provided as a template argument.
Not thread-safe.
Definition at line 24 of file allocator.h.
typedef const T* CppCommon::Allocator< T, TMemoryManager, nothrow >::const_pointer |
Pointer to constant element.
Definition at line 37 of file allocator.h.
typedef const T& CppCommon::Allocator< T, TMemoryManager, nothrow >::const_reference |
Reference to constant element.
Definition at line 39 of file allocator.h.
typedef ptrdiff_t CppCommon::Allocator< T, TMemoryManager, nothrow >::difference_type |
Difference between two pointers.
Definition at line 43 of file allocator.h.
typedef T* CppCommon::Allocator< T, TMemoryManager, nothrow >::pointer |
Pointer to element.
Definition at line 33 of file allocator.h.
typedef T& CppCommon::Allocator< T, TMemoryManager, nothrow >::reference |
Reference to element.
Definition at line 35 of file allocator.h.
typedef size_t CppCommon::Allocator< T, TMemoryManager, nothrow >::size_type |
Quantities of elements.
Definition at line 41 of file allocator.h.
typedef T CppCommon::Allocator< T, TMemoryManager, nothrow >::value_type |
Element type.
Definition at line 31 of file allocator.h.
|
inlineexplicitnoexcept |
Initialize allocator with a given memory manager.
manager | - Memory manager |
Definition at line 49 of file allocator.h.
|
inlinenoexcept |
Definition at line 51 of file allocator.h.
|
inlinenoexcept |
Definition at line 52 of file allocator.h.
|
defaultnoexcept |
|
defaultnoexcept |
|
inlinenoexcept |
Get the constant address of the given constant reference.
x | - Constant reference to the element |
Definition at line 74 of file allocator.h.
|
inlinenoexcept |
Get the address of the given reference.
x | - Reference to the element |
Definition at line 68 of file allocator.h.
|
inline |
Allocate a block of storage suitable to contain the given count of elements.
num | - Number of elements to be allocated |
hint | - Allocation hint (default is 0) |
Definition at line 29 of file allocator.inl.
|
inline |
Constructs an element object on the given location pointer.
ptr | - Pointer to a location with enough storage space to contain an element |
args | - Arguments to initialize the construced element with |
Definition at line 50 of file allocator.inl.
|
inline |
Create a single element object.
args | - Arguments to initialize the construced element with |
Definition at line 72 of file allocator.inl.
|
inline |
Create an array of element objects.
length | - Length of the array |
args | - Arguments to initialize the construced element with |
Definition at line 102 of file allocator.inl.
|
inline |
Release a block of storage previously allocated.
ptr | - Pointer to a block of storage |
num | - Number of releasing elements |
Definition at line 43 of file allocator.inl.
|
inline |
Destroys in-place the object pointed by the given location pointer.
ptr | - Pointer to the object to be destroyed |
Definition at line 61 of file allocator.inl.
|
inlinenoexcept |
Get the maximum number of elements, that could potentially be allocated by the allocator.
Definition at line 80 of file allocator.h.
|
defaultnoexcept |
|
inlinenoexcept |
Definition at line 59 of file allocator.h.
|
inlinenoexcept |
Definition at line 57 of file allocator.h.
|
inline |
Release a single element object.
ptr | - Pointer to the object to be released |
Definition at line 85 of file allocator.inl.
|
inline |
Release an array of element objects.
ptr | - Pointer to the object to be released |
Definition at line 124 of file allocator.inl.
|
inline |
Reset the allocator.
Definition at line 97 of file allocator.h.
|
friend |
Definition at line 27 of file allocator.h.