Base: Constrain size of Base::Type

This commit is contained in:
Benjamin Nauck
2025-02-13 20:25:43 +01:00
parent 9c173d2b35
commit 15c8ab5b4f

View File

@@ -33,6 +33,15 @@
using namespace Base;
static_assert(sizeof(Base::Type) == sizeof(unsigned int),
"Base::Type has been designed to be small to be passed around by value efficiently. "
"The size of Base::Type has changed. Be careful when adding more data members.");
static_assert(
sizeof(Base::Type) <= 2 * sizeof(void*),
"Base::Type has been designed to be small to be passed around by value efficiently. "
"When the size grows larger than ~2 words, consider passing by const reference instead. "
"Exact limit depends on the architecture and ABI.");
struct Base::TypeData
{