From: Alec Thomas Date: Wed, 13 Aug 2014 22:55:51 +0000 (+1000) Subject: Use std::abort() if exceptions are disabled. X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=0db983990d66132bd8a0cef594de9c1db9ebe0a4;p=clyne%2Fentityx.git Use std::abort() if exceptions are disabled. Fixes #47. --- diff --git a/entityx/Entity.h b/entityx/Entity.h index c56b37d..6e5eda7 100644 --- a/entityx/Entity.h +++ b/entityx/Entity.h @@ -220,24 +220,19 @@ struct BaseComponent { // NOTE: Component memory is *always* managed by the EntityManager. // Use Entity::destroy() instead. - void operator delete(void *p) { -#ifdef _HAS_EXCEPTIONS - throw std::bad_alloc(); -#else - abort(); -#endif - } + void operator delete(void *p) { fail(); } + void operator delete[](void *p) { fail(); } + - void operator delete[](void *p) { -#ifdef _HAS_EXCEPTIONS + protected: + void fail() { +#if defined(_HAS_EXCEPTIONS) || defined(__EXCEPTIONS) throw std::bad_alloc(); #else - abort(); + std::abort(); #endif - } - - protected: + } static Family family_counter_; };