diff options
author | Benoit Jacob <jacob.benoit.1@gmail.com> | 2009-05-15 15:53:26 +0000 |
---|---|---|
committer | Benoit Jacob <jacob.benoit.1@gmail.com> | 2009-05-15 15:53:26 +0000 |
commit | 126284d08bcf9abb3a6665bf31305a188371e461 (patch) | |
tree | 5e489d9ba4b4eb4b3fff97d5f27531301f8659d6 /Eigen | |
parent | 7c14e1eac4b70dda9d9fa2ec1191694f8d353d33 (diff) |
* fix bugs in EigenTesting.cmake: it didn't work with -DEIGEN_NO_ASSERTION_CHECKING=ON
* only try...catch if exceptions are enabled
Diffstat (limited to 'Eigen')
-rw-r--r-- | Eigen/src/Core/util/Memory.h | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h index 510f73729..dd6c53f56 100644 --- a/Eigen/src/Core/util/Memory.h +++ b/Eigen/src/Core/util/Memory.h @@ -233,6 +233,20 @@ inline static int ei_alignmentOffset(const Scalar* ptr, int maxOffset) #if EIGEN_ALIGN + #ifdef EIGEN_EXCEPTIONS + #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \ + void* operator new(size_t size, const std::nothrow_t&) throw() { \ + try { return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); } \ + catch (...) { return 0; } \ + return 0; \ + } + #else + #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \ + void* operator new(size_t size, const std::nothrow_t&) { \ + return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); \ + } + #endif + #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) \ void *operator new(size_t size) { \ return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); \ @@ -248,11 +262,7 @@ inline static int ei_alignmentOffset(const Scalar* ptr, int maxOffset) static void *operator new(size_t size, void *ptr) { return ::operator new(size,ptr); } \ void operator delete(void * memory, void *ptr) throw() { return ::operator delete(memory,ptr); } \ /* nothrow-new (returns zero instead of std::bad_alloc) */ \ - void* operator new(size_t size, const std::nothrow_t&) throw() { \ - try { return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); } \ - catch (...) { return 0; } \ - return 0; \ - } \ + EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \ void operator delete(void *ptr, const std::nothrow_t&) throw() { \ Eigen::ei_conditional_aligned_free<NeedsToAlign>(ptr); \ } \ |