diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index 4851036e4..260e8c0ff 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -117,17 +117,9 @@ struct ei_traits > }; }; -template -struct ei_matrix_with_aligned_operator_new : WithAlignedOperatorNew {}; - -template -struct ei_matrix_with_aligned_operator_new {}; - template class Matrix : public MatrixBase > - , public ei_matrix_with_aligned_operator_new<_Scalar, _Rows, _Cols, _Options> { public: EIGEN_GENERIC_PUBLIC_INTERFACE(Matrix) @@ -140,6 +132,23 @@ class Matrix protected: ei_matrix_storage m_storage; + public: // FIXME should this be public? I'd say yes but I still don't understand then why at other places we've been having private new and delete operators. + enum { NeedsToAlign = (Options&Matrix_AutoAlign) == Matrix_AutoAlign + && SizeAtCompileTime!=Dynamic && ((sizeof(Scalar)*SizeAtCompileTime)%16)==0 }; + typedef typename ei_meta_if::ret ByteAlignedAsNeeded; + void *operator new(size_t size) throw() + { + return ei_aligned_malloc(size); + } + + void *operator new[](size_t size) throw() + { + return ei_aligned_malloc(size); + } + + void operator delete(void * ptr) { ei_aligned_free(static_cast(ptr), 0); } + void operator delete[](void * ptr) { ei_aligned_free(static_cast(ptr), 0); } + public: EIGEN_STRONG_INLINE int rows() const { return m_storage.rows(); }