|
CppCommon 1.0.5.0
C++ Common Library
|
Memory allocator class. More...
#include <allocator.h>
Classes | |
| struct | rebind |
| Rebind allocator. More... | |
Public Types | |
| typedef T | value_type |
| Element type. | |
| typedef T * | pointer |
| Pointer to element. | |
| typedef T & | reference |
| Reference to element. | |
| typedef const T * | const_pointer |
| Pointer to constant element. | |
| typedef const T & | const_reference |
| Reference to constant element. | |
| typedef size_t | size_type |
| Quantities of elements. | |
| typedef ptrdiff_t | difference_type |
| Difference between two pointers. | |
Public Member Functions | |
| Allocator (TMemoryManager &manager) noexcept | |
| Initialize allocator with a given memory manager. | |
| 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. | |
| const_pointer | address (const_reference x) const noexcept |
| Get the constant address of the given constant reference. | |
| size_type | max_size () const noexcept |
| Get the maximum number of elements, that could potentially be allocated by the allocator. | |
| pointer | allocate (size_type num, const void *hint=0) |
| Allocate a block of storage suitable to contain the given count of elements. | |
| void | deallocate (pointer ptr, size_type num) |
| Release a block of storage previously allocated. | |
| void | reset () |
| Reset the allocator. | |
| template<typename U , class... Args> | |
| void | construct (U *ptr, Args &&... args) |
| Constructs an element object on the given location pointer. | |
| template<typename U > | |
| void | destroy (U *ptr) |
| Destroys in-place the object pointed by the given location pointer. | |
| template<class... Args> | |
| T * | Create (Args &&... args) |
| Create a single element object. | |
| void | Release (T *ptr) |
| Release a single element object. | |
| template<class... Args> | |
| T * | CreateArray (size_t length, Args &&... args) |
| Create an array of element objects. | |
| void | ReleaseArray (T *ptr) |
| Release an array of element objects. | |
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.