diff --git a/src/xrCommon/xr_unordered_map.h b/src/xrCommon/xr_unordered_map.h index 1f9e8055eac..f48927d94c4 100644 --- a/src/xrCommon/xr_unordered_map.h +++ b/src/xrCommon/xr_unordered_map.h @@ -2,6 +2,6 @@ #include #include "xrCore/Memory/XRayAllocator.hpp" -template , class KeyEqual = std::equal_to, - class allocator = XRay::xray_allocator>> -using xr_unordered_map = std::unordered_map; +template , class Traits = std::equal_to, + typename allocator = XRay::xray_allocator>> +using xr_unordered_map = std::unordered_map; diff --git a/src/xrCore/Memory/xalloc.h b/src/xrCore/Memory/xalloc.h index 7b776eb1b30..98519e45850 100644 --- a/src/xrCore/Memory/xalloc.h +++ b/src/xrCore/Memory/xalloc.h @@ -1,44 +1,45 @@ #pragma once #include "xrCore/xrMemory.h" -template +template class xalloc { public: - typedef size_t size_type; - typedef std::ptrdiff_t difference_type; - typedef T* pointer; - typedef const T* const_pointer; - typedef T& reference; - typedef const T& const_reference; - typedef T value_type; + using size_type = size_t; + using difference_type = std::ptrdiff_t; + using pointer = T*; + using const_pointer = const T*; + using reference = T&; + using const_reference = const T&; + using value_type = T; -public: - template + template struct rebind { - typedef xalloc<_Other> other; + using other = xalloc; }; -public: - pointer address(reference _Val) const { return &_Val; } - const_pointer address(const_reference _Val) const { return &_Val; } - xalloc() {} - xalloc(const xalloc&) {} - template - xalloc(const xalloc<_Other>&) {} - template - xalloc& operator=(const xalloc<_Other>&) { return *this; } - pointer allocate(size_type n, const void* p = nullptr) const { return xr_alloc(n); } - char* _charalloc(size_type n) { return (char*)allocate(n); } - void deallocate(pointer p, size_type n) const { xr_free(p); } - void deallocate(void* p, size_type n) const { xr_free(p); } - void construct(pointer p, const T& _Val) { new(p) T(_Val); } + pointer address(reference ref) const { return &ref; } + const_pointer address(const_reference ref) const { return &ref; } + + xalloc() = default; + xalloc(const xalloc&) = default; + + template + xalloc(const xalloc&) {} + + template + xalloc& operator=(const xalloc&) { return *this; } + + pointer allocate(const size_type n, const void* p = nullptr) const { return xr_alloc(n); } + void deallocate(pointer p, const size_type /*n*/) const { xr_free(p); } + void deallocate(void* p, const size_type /*n*/) const { xr_free(p); } + void construct(pointer p, const T& ref) { new(p) T(ref); } void destroy(pointer p) { p->~T(); } size_type max_size() const { - size_type _Count = (size_type)(-1)/sizeof(T); - return 0<_Count ? _Count : 1; + constexpr auto count = std::numeric_limits::max() / sizeof(T); + return 0 < count ? count : 1; } }; @@ -47,16 +48,16 @@ struct xr_allocator template struct helper { - typedef xalloc result; + using result = xalloc; }; - static void* alloc(const u32& n) { return xr_malloc((u32)n); } + static void* alloc(const size_t n) { return xr_malloc(n); } template static void dealloc(T*& p) { xr_free(p); } }; -template -inline bool operator==(const xalloc<_Ty>&, const xalloc<_Other>&) { return true; } +template +bool operator==(const xalloc&, const xalloc&) { return true; } -template -inline bool operator!=(const xalloc<_Ty>&, const xalloc<_Other>&) { return false; } +template +bool operator!=(const xalloc&, const xalloc&) { return false; } diff --git a/src/xrCore/xrMemory.h b/src/xrCore/xrMemory.h index c073baecdd0..854dcc64925 100644 --- a/src/xrCore/xrMemory.h +++ b/src/xrCore/xrMemory.h @@ -117,7 +117,7 @@ IC void xr_free(T*& P) throw() if (P) { Memory.mem_free((void*)P); - P = NULL; + P = nullptr; }; }