VERY experimental Nintendo Switch 2 emulator
C++
virtual_buffer: Add compile-time type-safety guarantees with VirtualBuffer
Lioncashd02005bbe9f9
diff --git a/src/common/virtual_buffer.h b/src/common/virtual_buffer.hindex 363913d452..078e61c775 100644--- a/src/common/virtual_buffer.h+++ b/src/common/virtual_buffer.h@@ -4,6 +4,7 @@#pragma once+#include <type_traits>#include <utility>namespace Common {@@ -14,6 +15,11 @@ void FreeMemoryPages(void* base, std::size_t size) noexcept;template <typename T>class VirtualBuffer final {public:+ static_assert(+ std::is_trivially_constructible_v<T>,+ "T must be trivially constructible, as non-trivial constructors will not be executed "+ "with the current allocator");+constexpr VirtualBuffer() = default;explicit VirtualBuffer(std::size_t count) : alloc_size{count * sizeof(T)} {base_ptr = reinterpret_cast<T*>(AllocateMemoryPages(alloc_size));