GS: Use static_assert over assert where possible

This commit is contained in:
TellowKrinkle 2021-11-26 18:32:00 -06:00 committed by lightningterror
parent 38ab0630e6
commit 31b6ff6046
1 changed files with 2 additions and 2 deletions

View File

@ -207,12 +207,12 @@ public:
SharedPtr<T> make_shared(Args&&... args)
{
using Header = typename SharedPtr<T>::AllocationHeader;
size_t alloc_size = sizeof(T) + sizeof(Header);
constexpr size_t alloc_size = sizeof(T) + sizeof(Header);
static_assert(alignof(Header) <= MIN_ALIGN, "Header alignment too high");
static_assert(alloc_size <= UINT32_MAX, "Allocation overflow");
void* ptr = alloc_internal(sizeof(T), getAlignMask(alignof(T)), sizeof(Header));
Header* header = static_cast<Header*>(ptr);
assert(alloc_size <= UINT32_MAX && "Allocation overflow");
header->size = static_cast<uint32_t>(alloc_size);
header->refcnt.store(1, std::memory_order_relaxed);