1#ifndef NNGN_UTILS_ALLOC_TRACKING_H
2#define NNGN_UTILS_ALLOC_TRACKING_H
22 requires(
T t,
typename T::pointer p, std::size_t
n) {
23 t.reallocate_pre(p,
n);
36 requires(
T t,
typename T::pointer p, std::size_t
n) {
38 typename T::value_type;
41 typename T::template rebind<empty>;
45 && (!
requires { T::reallocate; } || detail::tracker_with_realloc<T>);
73template<alloc_tracker T,
typename A = std::allocator<
typename T::value_type>>
81 typename std::allocator_traits<A>::template rebind_alloc<value_type>;
100 template<alloc_tracker T1,
typename A1>
118 p = this->
alloc.reallocate(p,
n);
130template<alloc_tracker T,
typename A>
132 : m_tracker{
std::
move(t)}, alloc{rhs.alloc} {}
134template<alloc_tracker T,
typename A>
136 : m_tracker{rhs.tracker()}, alloc{rhs.alloc} {}
138template<alloc_tracker T,
typename A>
139template<alloc_tracker T1,
typename A1>
142 : m_tracker{rhs.tracker()}, alloc{rhs.get_allocator()} {}
144template<alloc_tracker T,
typename A>
148 this->alloc = rhs.
alloc;
152template<alloc_tracker T,
typename A>
154 auto *
const ret = this->alloc.allocate(
n);
155 this->m_tracker.allocate(ret,
n);
159template<alloc_tracker T,
typename A>
163 requires has_typed_alloc<I>
165 auto *
const ret = this->alloc.allocate(
n);
166 this->m_tracker.allocate(ret,
n, ti);
170template<alloc_tracker T,
typename A>
174 this->m_tracker.deallocate(p,
n);
175 this->alloc.deallocate(p,
n);
local class const
Definition animation.lua:7
Allocator which tracks the amount of memory allocated.
Definition tracking.h:76
typename T::value_type value_type
Definition tracking.h:78
static bool constexpr has_typed_alloc
Definition tracking.h:84
pointer allocate(std::size_t n, I i) noexcept
tracking_allocator(T t)
Definition tracking.h:97
tracking_allocator & operator=(const tracking_allocator &rhs)
Definition tracking.h:145
allocator alloc
Definition tracking.h:127
T m_tracker
Definition tracking.h:126
const T & tracker(void) const
Definition tracking.h:109
typename std::allocator_traits< A >::template rebind_alloc< value_type > allocator
Definition tracking.h:80
T & tracker(void)
Definition tracking.h:108
pointer reallocate(pointer p, std::size_t n) noexcept
Definition tracking.h:114
tracking_allocator(void)=default
void deallocate(pointer p, std::size_t n) noexcept
Definition tracking.h:171
const allocator & get_allocator(void) const
Definition tracking.h:107
pointer allocate(std::size_t n) noexcept
Definition tracking.h:153
tracking_allocator(tracking_allocator &&) noexcept=default
Describes how allocations of a particular type are tracked.
Definition tracking.h:35
Checks whether the tracker object tracks memory relocation.
Definition tracking.h:21
Definition fundamental.h:41
for i
Definition font.lua:5
local n
Definition dump_lights.lua:5
static constexpr bool has_realloc
Checks whether an allocator supports memory relocation.
Definition base.h:83
move
Definition camera.lua:57
Base class for allocators, implements a few basic operations.
Definition base.h:49