Move compile asserts out, as g++ can't use AllocByteSize in class def

This commit is contained in:
baldurk
2015-09-17 17:28:52 +02:00
parent 5bb681033d
commit 250b59e07c
+10 -8
View File
@@ -130,15 +130,18 @@ class WrappingPool
#endif
}
static const size_t AllocCount = PoolCount;
static const size_t AllocMaxByteSize = MaxPoolByteSize;
static const size_t AllocByteSize;
private:
WrappingPool()
{
#ifdef INCLUDE_TYPE_NAMES
RDCDEBUG("WrappingPool<%s> %d in %.2fMB: %p -> %p", GetTypeName<WrapType>::Name(), PoolCount, float(PoolCount*AllocByteSize)/(1024.0f*1024.0f), &m_ImmediatePool.items[0], &m_ImmediatePool.items[AllocCount-1]);
// hack - print in kB because float printing relies on statics that might not be initialised
// yet in loading order. Ugly :(
RDCDEBUG("WrappingPool<%s> %d in %dkB: %p -> %p", GetTypeName<WrapType>::Name(), PoolCount, (PoolCount*AllocByteSize)/1024, &m_ImmediatePool.items[0], &m_ImmediatePool.items[AllocCount-1]);
#endif
RDCCOMPILE_ASSERT(PoolCount*AllocByteSize <= MaxPoolByteSize, "Pool is bigger than max pool size cap");
RDCCOMPILE_ASSERT(PoolCount > 2, "Pool isn't greater than 2 in size. Bad parameters?"); // make sure parameters are sane
}
~WrappingPool()
{
@@ -148,9 +151,6 @@ class WrappingPool
m_AdditionalPools.clear();
}
static const size_t AllocCount = PoolCount;
static const size_t AllocByteSize;
Threading::CriticalSection m_Lock;
struct ItemPool
@@ -259,5 +259,7 @@ class WrappingPool
#define WRAPPED_POOL_INST(a) \
a::PoolType a::m_Pool; \
const size_t a::PoolType::AllocByteSize = sizeof(a); \
template<> const size_t a::PoolType::AllocByteSize = sizeof(a); \
RDCCOMPILE_ASSERT(a::PoolType::AllocCount*a::PoolType::AllocByteSize <= a::PoolType::AllocMaxByteSize, "Pool is bigger than max pool size cap"); \
RDCCOMPILE_ASSERT(a::PoolType::AllocCount > 2, "Pool isn't greater than 2 in size. Bad parameters?"); \
DECL_TYPENAME(a);