Implementation of std::allocator
to be used with container types provided by the C++ standard library.
This allocator only optionally uses monotonic allocation - only if an allocator was given with construction. This has a very small performance impact, hence the non-optional sibling, StdContMA is to be used with types that always use monotonic memory.
T | The type of objects to be allocated. |
Definition at line 239 of file stdcontainerma.hpp.
#include <stdcontainerma.hpp>
Public Field Index: | |
MonoAllocator * | allocator |
bool | dbgDeallocationWarning |
Public Method Index: | |
constexpr | StdContMAOptional () |
constexpr | StdContMAOptional (const StdContMAOptional &) noexcept=default |
constexpr | StdContMAOptional (MonoAllocator &pAllocator, bool dbgDeallocationWarning=true) |
constexpr | StdContMAOptional (StdContMAOptional &&) noexcept=default |
template<typename TSibling > | |
StdContMAOptional (TSibling &origin) | |
T * | allocate (size_t n, const void *=nullptr) |
void | deallocate (T *p, std::size_t n) |
template<typename U > | |
bool | operator!= (const StdContMAOptional< U > &rhs) const noexcept |
template<typename U > | |
bool | operator== (const StdContMAOptional< U > &rhs) const noexcept |
Public Method Index: inherited from StdContainerMABase< T > | |
size_t | max_size () const noexcept |
Additional Inherited Members | |
Public Type Index: inherited from StdContainerMABase< T > | |
using | difference_type = ptrdiff_t |
Type definition as required by C++ library standards. | |
using | is_always_equal = std::false_type |
Type definition as required by C++ library standards. | |
using | size_type = size_t |
Type definition as required by C++ library standards. | |
using | value_type = T |
Type definition as required by C++ library standards. | |
MonoAllocator* allocator |
The allocator to use.
Definition at line 245 of file stdcontainerma.hpp.
bool dbgDeallocationWarning |
If true
warnings about de-allocation of objects are suppressed. this should be set prior to destructing a container that uses this allocator.
Available only in debug builds.
Definition at line 251 of file stdcontainerma.hpp.
|
inlineconstexpr |
Default constructor
Definition at line 258 of file stdcontainerma.hpp.
|
constexprdefaultnoexcept |
Defaulted copy constructor
|
constexprdefaultnoexcept |
Defaulted move constructor
Copy constructor using an instance of different template type.
TSibling | The originating allocator's type (StdContMAOptional<X>). |
origin | The originating allocator of type TSibling . |
Definition at line 275 of file stdcontainerma.hpp.
|
constexpr |
Constructor for the initial allocator instantiation.
Parameter dbgDisableDeallocationWarning , which defaults to true
might be given after a code is tested to be stict in respect to allocation. (Note: unfortunately, due to the design of std::allocator
and its use, this flag can not be changed once a container is constructed. This is why it has to be decided upfront if a warning is to be raised or not).
pAllocator | The recycler for allocations and de-allocations. |
dbgDeallocationWarning | As described with this method. Available only in debug builds. |
|
inline |
If allocator is set, passes the allocation request to allocator. Otherwise invokes std::malloc
.
n | The number of requested objects to allocate storage for. |
Definition at line 343 of file stdcontainerma.hpp.
|
inline |
If allocator is not set, invokes std::free(p)
. Otherwise does nothing.
p | Pointer to the previously allocated memory. |
n | The number of objects allocated. |
Definition at line 361 of file stdcontainerma.hpp.
|
inlinenoexcept |
Comparison operator.
U | The allocation type of the other allocator. |
rhs | The right hand side allocator. |
false
if this and rhs use the same allocator, true
otherwise. Definition at line 325 of file stdcontainerma.hpp.
|
inlinenoexcept |
Comparison operator.
U | The allocation type of the other allocator. |
rhs | The right hand side allocator. |
true
if this and rhs use the same allocator, false
otherwise. Definition at line 313 of file stdcontainerma.hpp.