diff options
Diffstat (limited to '')
| -rw-r--r-- | src/common/virtual_buffer.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/common/virtual_buffer.h b/src/common/virtual_buffer.h index 363913d45..078e61c77 100644 --- a/src/common/virtual_buffer.h +++ b/src/common/virtual_buffer.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <type_traits> | ||
| 7 | #include <utility> | 8 | #include <utility> |
| 8 | 9 | ||
| 9 | namespace Common { | 10 | namespace Common { |
| @@ -14,6 +15,11 @@ void FreeMemoryPages(void* base, std::size_t size) noexcept; | |||
| 14 | template <typename T> | 15 | template <typename T> |
| 15 | class VirtualBuffer final { | 16 | class VirtualBuffer final { |
| 16 | public: | 17 | public: |
| 18 | static_assert( | ||
| 19 | std::is_trivially_constructible_v<T>, | ||
| 20 | "T must be trivially constructible, as non-trivial constructors will not be executed " | ||
| 21 | "with the current allocator"); | ||
| 22 | |||
| 17 | constexpr VirtualBuffer() = default; | 23 | constexpr VirtualBuffer() = default; |
| 18 | explicit VirtualBuffer(std::size_t count) : alloc_size{count * sizeof(T)} { | 24 | explicit VirtualBuffer(std::size_t count) : alloc_size{count * sizeof(T)} { |
| 19 | base_ptr = reinterpret_cast<T*>(AllocateMemoryPages(alloc_size)); | 25 | base_ptr = reinterpret_cast<T*>(AllocateMemoryPages(alloc_size)); |