1#ifndef NEFORCE_CORE_MEMORY_TRACE_MEMORY_HPP__
2#define NEFORCE_CORE_MEMORY_TRACE_MEMORY_HPP__
16NEFORCE_BEGIN_NAMESPACE__
35 static_assert(
is_allocable_v<T>,
"allocator can`t alloc void, reference, function or const type.");
40 using const_pointer =
const T*;
42 using const_reference =
const T&;
72 traces_(other.traces_) {}
83 traces_ = other.traces_;
93 if (!traces_.empty()) {
105 for (
auto& entry: traces_) {
106 if (entry.first == 0) {
121 NEFORCE_NODISCARD NEFORCE_ALLOC_OPTIMIZE pointer
allocate(
const size_type n) {
124 traces_[ptr] = _NEFORCE
move(st);
144 auto it = traces_.find(p);
145 if (it != traces_.end()) {
170template <
typename T,
typename U>
183template <
typename T,
typename U>
190NEFORCE_END_NAMESPACE__
static constexpr color red() noexcept
红色
void print_stacktrace() const
打印所有未释放内存的调用栈
void deallocate(pointer p) noexcept
释放单个元素的内存
trace_allocator()=default
默认构造函数
NEFORCE_NODISCARD NEFORCE_ALLOC_OPTIMIZE pointer allocate()
分配单个元素的内存
NEFORCE_NODISCARD NEFORCE_ALLOC_OPTIMIZE pointer allocate(const size_type n)
分配内存
trace_allocator & operator=(const trace_allocator &other)
拷贝赋值运算符
void deallocate(pointer p, const size_type n) noexcept
释放内存
trace_allocator(const trace_allocator &other)
拷贝构造函数
NEFORCE_NODISCARD constexpr T * addressof(T &x) noexcept
获取对象的地址
NEFORCE_INLINE17 constexpr bool is_allocable_v
is_allocable的便捷变量模板
void printcln(const color &color, Args &&... args)
带颜色打印多个值并换行
standard_allocator< T > allocator
标准分配器别名
constexpr Iterator2 move(Iterator1 first, Iterator1 last, Iterator2 result) noexcept(noexcept(inner::__move_aux(first, last, result)))
移动范围元素
bool operator!=(const trace_allocator< T > &lhs, const trace_allocator< U > &rhs) noexcept
不等比较运算符
bool operator==(const trace_allocator< T > &lhs, const trace_allocator< U > &rhs) noexcept
相等比较运算符