aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlec Thomas <alec@swapoff.org>2014-08-14 08:55:51 +1000
committerAlec Thomas <alec@swapoff.org>2014-08-14 08:56:33 +1000
commit0db983990d66132bd8a0cef594de9c1db9ebe0a4 (patch)
treec77158a32b9fb46d2a38356a51914d2e9f0a88f7
parent17b51d775875c9eea7313d70764623250c941870 (diff)
Use std::abort() if exceptions are disabled.
Fixes #47.
-rw-r--r--entityx/Entity.h21
1 files changed, 8 insertions, 13 deletions
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_;
};