Do the memory alignment issues with Eigen listed in the documentation still apply with C++11? It seems that C++11 can already take care of properly aligning objects on the stack and on the heap, with alignas
and std::allocator
which supports alignment.
Yes, the alignment issues are still present in C++11. The alignas
specifier has no effect on dynamic allocations, which can thus still cause misalignments resulting in assertions thrown by Eigen.
You will have to continue to use the facilities Eigen provides for aligned allocation, such as EIGEN_MAKE_ALIGNED_OPERATOR_NEW
for allocating objects or Eigen::aligned_allocator<T>
for aligning containers.
While the question is about C++11 specifically, it is worth noting that a combination of the upcoming Eigen version 3.4 with a C++17 compliant compiler will free us from the need to use EIGEN_MAKE_ALIGNED_OPERATOR_NEW
and Eigen::aligned_allocator<T>
. The former macro is actually even empty then. This is possible by a new form of operator new
that is specifically designed to support overalignment.
© 2022 - 2024 — McMap. All rights reserved.
std::vector
, and the macro to overloadoperator new
in classes that contain Eigen objects. Because in C++11 memory alignment seems to be supported for for stack and heap memory. – Adeliaadelice