25#ifndef COUNTING_CALLOCATOR_HPP
26#define COUNTING_CALLOCATOR_HPP
76 constexpr void flush_stats() noexcept {
89 return jau_format_string(
"CCAlloc[%'zu bytes, alloc[balance %'zd = %'zu - %'zu, realloc %'zu]]",
100#if __cplusplus > 201703L
120#if __cplusplus > 201703L
121 template <
typename U>
131 template <
typename U>
142#if __cplusplus > 201703L
148#if __cplusplus <= 201703L
158#if __cplusplus > 201703L
179 if(
nullptr != res ) {
187#if __cplusplus > 201703L
207#if __cplusplus > 201703L
208template <
class T1,
class T2>
209 constexpr bool operator==(
const counting_callocator<T1>& lhs,
const counting_callocator<T2>& rhs)
noexcept {
214 return lhs.memory_usage == rhs.memory_usage;
222 template <
class T1,
class T2>
228 return lhs.memory_usage == rhs.memory_usage;
235 template <
class T1,
class T2>
#define jau_format_string(fmt,...)
Macro, safely returns a (non-truncated) string according to snprintf() formatting rules using a reser...
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
bool operator==(const callocator< T1 > &lhs, const callocator< T2 > &rhs) noexcept
bool operator!=(const callocator< T1 > &lhs, const callocator< T2 > &rhs) noexcept
A simple allocator using POSIX C functions: ::malloc(), ::free() and ::realloc().
callocator() noexcept=default
void deallocate(value_type *p, std::size_t) noexcept
constexpr value_type * reallocate(value_type *p, std::size_t, std::size_t new_size)
value_type * allocate(std::size_t n, const void *)
counting_callocator< U > other
Performance counter jau::callocator specialization.
constexpr value_type * reallocate(value_type *p, std::size_t old_size, std::size_t new_size)
value_type * allocate(std::size_t n, const void *hint)
std::size_t dealloc_count
~counting_callocator()=default
std::size_t realloc_count
counting_callocator(const counting_callocator< U > &other) noexcept
counting_callocator(const counting_callocator &other) noexcept
void deallocate(value_type *p, std::size_t n)
value_type * allocate(std::size_t n)
counting_callocator() noexcept