#include <new>

#define DECLARE_MEMORY_POOL(Cls) \
    public: \
        static void* operator new(size_t _size) \
        { \
            assert(_size == sizeof(Cls)); \
            void* _ptr = MemoryPool<sizeof(Cls)>::instance().allocate(); \
            if (_ptr) \
                return _ptr; \
            else \
                throw std::bad_alloc(); \
        } \
        static void operator delete(void* _ptr) \
        { \
            if (_ptr != NULL) \
                MemoryPool<sizeof(Cls)>::instance().deallocate(_ptr); \
        }

#define DECLARE_MEMORY_POOL__NOTHROW(Cls) \
    public: \
        static void* operator new(size_t _size) throw() \
        { \
            assert(_size == sizeof(Cls)); \
            return MemoryPool<sizeof(Cls)>::instanceKnown().allocate(); \
        } \
        static void operator delete(void* _ptr) \
        { \
            if (_ptr != NULL) \
                MemoryPool<sizeof(Cls)>::instanceKnown().deallocate(_ptr); \
        }

#define PREPARE_MEMORY_POOL(Cls) \
    MemoryPool<sizeof(Cls)>::instance()