「this」ポインタを参照する静的アサートを書くことは可能ですか? 私は c++11 を利用できず、BOOST_STATIC_ASSERT が機能しません。
struct blah
{
void func() {BOOST_STATIC_ASSERT(sizeof(*this));}
};
プロデュース:
error C2355: 'this' : can only be referenced inside non-static member functions
error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE'
MSVC 2008 で。
動機:
#define CLASS_USES_SMALL_POOL() \
void __small_pool_check() {BOOST_STATIC_ASSERT(sizeof(*this) < SMALL_MALLOC_SIZE;} \
void* operator new(size_t) {return SmallMalloc();} \
void operator delete(void* p) {SmallFree(p);}