Registered Member
|
I've a class foo containing a class bar
foo is instantiated with
This crashes with the error described here http://eigen.tuxfamily.org/dox/UnalignedArrayAssert.html. Adding EIGEN_MAKE_ALIGNED_OPERATOR_NEW to foo fixes this problem. The question is, does EIGEN_MAKE_ALIGNED_OPERATOR_NEW have to specified for all classes that contain classes (that contain classes etc) that contain Eigen types? We tend not to use the new keyword but instantiate classes directly. |
Registered Member
|
Yes. This is really just a C++ issue: when class A has a data member of type B, just because B::operator new is overloaded doesn't do anything to A::operator new. So in order for 'new A' to work, you really need to overload A's operator new.
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered Member
|
Do we also need to overload class bar's new operator in this example? And is there a drawback of specifying EIGEN_MAKE_ALIGNED_OPERATOR_NEW when it is not necessary (for example, in a class never created using new or with no Eigen members)? |
Registered Member
|
Only if you want to do 'new bar'.
There's no significant drawback that I can see. Aligned memory allocation can be a bit slower (during the allocation itself), but that's it.
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], q.ignora