diff --git a/src/memory.hh b/src/memory.hh index 163dd76c0..3c45f392d 100644 --- a/src/memory.hh +++ b/src/memory.hh @@ -132,7 +132,7 @@ bool operator!=(const Allocator& lhs, const Allocator& rhs) template struct TypeDomain { - static constexpr MemoryDomain domain = TypeDomain::helper((T*)nullptr); + static constexpr MemoryDomain domain() { return TypeDomain::helper((T*)nullptr); } private: template static decltype(U::Domain) constexpr helper(U*) { return U::Domain; } static constexpr MemoryDomain helper(...) { return MemoryDomain::Undefined; } @@ -141,16 +141,21 @@ private: template struct UseMemoryDomain { - static constexpr MemoryDomain domain = d; + static constexpr MemoryDomain Domain = d; static void* operator new(size_t size) { - on_alloc(domain, size); + on_alloc(Domain, size); return ::operator new(size); } + static void* operator new(size_t size, void* ptr) + { + return ::operator new(size, ptr); + } + static void operator delete(void* ptr, size_t size) { - on_dealloc(domain, size); + on_dealloc(Domain, size); ::operator delete(ptr); } }; diff --git a/src/unordered_map.hh b/src/unordered_map.hh index 2c54a0dac..13246fac6 100644 --- a/src/unordered_map.hh +++ b/src/unordered_map.hh @@ -9,7 +9,7 @@ namespace Kakoune { -template::domain> +template::domain()> using UnorderedMap = std::unordered_map, std::equal_to, Allocator, domain>>; diff --git a/src/vector.hh b/src/vector.hh index db137b244..c8cc9d086 100644 --- a/src/vector.hh +++ b/src/vector.hh @@ -8,7 +8,7 @@ namespace Kakoune { -template::domain> +template::domain()> using Vector = std::vector>; }