nngn
|
Allocator which tracks the amount of memory allocated. More...
#include <tracking.h>
Classes | |
struct | rebind |
Public Types | |
using | value_type = typename T::value_type |
using | pointer = typename T::pointer |
using | allocator |
Public Member Functions | |
tracking_allocator (void)=default | |
tracking_allocator (T t) | |
tracking_allocator (T t, const tracking_allocator &rhs) | |
tracking_allocator (const tracking_allocator &rhs) | |
template<alloc_tracker T1, typename A1 > | |
tracking_allocator (const tracking_allocator< T1, A1 > &rhs) | |
tracking_allocator & | operator= (const tracking_allocator &rhs) |
tracking_allocator (tracking_allocator &&) noexcept=default | |
tracking_allocator & | operator= (tracking_allocator &&) noexcept=default |
~tracking_allocator (void)=default | |
const allocator & | get_allocator (void) const |
T & | tracker (void) |
const T & | tracker (void) const |
pointer | allocate (std::size_t n) noexcept |
void | deallocate (pointer p, std::size_t n) noexcept |
pointer | reallocate (pointer p, std::size_t n) noexcept |
template<typename I > requires has_typed_alloc<I> | |
pointer | allocate (std::size_t n, I i) noexcept |
template<typename I > requires has_typed_alloc<I> | |
auto | allocate (std::size_t n, I ti) noexcept -> pointer |
Private Attributes | |
T | m_tracker = {} |
allocator | alloc = {} |
Static Private Attributes | |
template<typename I > | |
static bool constexpr | has_typed_alloc |
Allocator which tracks the amount of memory allocated.
This class exists mostly to conform to the allocator interface, the actual operations are delegated to the two template parameters, as described below.
The alloc_tracker type T
should be the one which actually implements the tracking operations. An object of this type is stored internally — so it should be some kind of reference if the allocator is frequently copied — and one of its corresponding methods is called for each operation:
allocate(p, n)
, where p
is the pointer just allocated.deallocate(p, n)
.In addition, the following methods are called if the base allocator supports them:
allocate(p, n, t)
, as above but with the allocation type.reallocate(p, n)
.T | Type which contains tracking data and to which tracking operations are delegated. |
A | Base allocator to which all memory allocations are delegated. |
using nngn::tracking_allocator< T, A >::allocator |
using nngn::tracking_allocator< T, A >::pointer = typename T::pointer |
using nngn::tracking_allocator< T, A >::value_type = typename T::value_type |
|
default |
|
inlineexplicit |
nngn::tracking_allocator< T, A >::tracking_allocator | ( | T | t, |
const tracking_allocator< T, A > & | rhs ) |
nngn::tracking_allocator< T, A >::tracking_allocator | ( | const tracking_allocator< T, A > & | rhs | ) |
nngn::tracking_allocator< T, A >::tracking_allocator | ( | const tracking_allocator< T1, A1 > & | rhs | ) |
|
defaultnoexcept |
|
default |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
inline |
auto nngn::tracking_allocator< T, A >::operator= | ( | const tracking_allocator< T, A > & | rhs | ) |
|
defaultnoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
|
private |
|
staticconstexprprivate |
|
private |