From 2c74626e66e5fd88683348f37f4b30ab397bf55b Mon Sep 17 00:00:00 2001 From: Shauren Date: Wed, 9 Jul 2025 12:20:10 +0200 Subject: Core/Random: Use standard aligned operator new and remove RandomEngine singleton instance (it is trivially constructible) --- src/common/Utilities/SFMTRand.h | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/common/Utilities/SFMTRand.h') diff --git a/src/common/Utilities/SFMTRand.h b/src/common/Utilities/SFMTRand.h index 7d9a820c487..26c1816f667 100644 --- a/src/common/Utilities/SFMTRand.h +++ b/src/common/Utilities/SFMTRand.h @@ -27,16 +27,12 @@ */ class SFMTRand { public: - SFMTRand(); - uint32 RandomUInt32(); // Output random bits - void* operator new(size_t size, std::nothrow_t const&); - void operator delete(void* ptr, std::nothrow_t const&); - void* operator new(size_t size); - void operator delete(void* ptr); - void* operator new[](size_t size, std::nothrow_t const&); - void operator delete[](void* ptr, std::nothrow_t const&); - void* operator new[](size_t size); - void operator delete[](void* ptr); + SFMTRand() noexcept; + uint32 RandomUInt32() noexcept; // Output random bits + void* operator new(size_t size) noexcept { return ::operator new (size, std::align_val_t(alignof(SFMTRand)), std::nothrow); } + void operator delete(void* ptr) noexcept { ::operator delete (ptr, std::align_val_t(alignof(SFMTRand)), std::nothrow); } + void* operator new[](size_t size) noexcept { return ::operator new[](size, std::align_val_t(alignof(SFMTRand)), std::nothrow); } + void operator delete[](void* ptr) noexcept { ::operator delete[](ptr, std::align_val_t(alignof(SFMTRand)), std::nothrow); } private: sfmt_t _state; }; -- cgit v1.2.3