diff options
author | Sven Gothel <[email protected]> | 2021-01-02 06:40:13 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2021-01-02 06:40:13 +0100 |
commit | 55e39f140a3cb335011e12f0d18f61f992d1465e (patch) | |
tree | a9c86b90e2d822b4e86c4f66bb2b0704381647d6 /include/jau/counting_allocator.hpp | |
parent | ce785560ce1ef7ae955798e09d094d7ae987e357 (diff) |
counting_allocator: Fix C++20 ctor; Add custom ctor to keep_stats
Diffstat (limited to 'include/jau/counting_allocator.hpp')
-rw-r--r-- | include/jau/counting_allocator.hpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/include/jau/counting_allocator.hpp b/include/jau/counting_allocator.hpp index 5eff9d5..5ec5ced 100644 --- a/include/jau/counting_allocator.hpp +++ b/include/jau/counting_allocator.hpp @@ -91,7 +91,7 @@ struct counting_allocator : public std::allocator<T> old_stats(true), memory_usage(other.memory_usage), alloc_count(other.alloc_count), dealloc_count(other.dealloc_count), - alloc_balance(other.alloc_balance)) + alloc_balance(other.alloc_balance) {} // C++20 #else counting_allocator(const counting_allocator& other) noexcept @@ -103,6 +103,14 @@ struct counting_allocator : public std::allocator<T> alloc_balance(other.alloc_balance) { } #endif + constexpr counting_allocator(const counting_allocator& other, const bool keep_stats) noexcept + : std::allocator<T>(other), + // id(next_id++), + old_stats(keep_stats ? false : true), + memory_usage(other.memory_usage), + alloc_count(other.alloc_count), dealloc_count(other.dealloc_count), + alloc_balance(other.alloc_balance) + {} #if __cplusplus > 201703L template <typename U> |