I have an class ClusterNode which contains an Eigen::Matrix4d as a class variable. I also have a function numNodes() which tells me the total number of ClusterNodes, so that I can collect them in some sort of array, list, or vector.
However, Eigen::Matrix4d is aligned which means I cannot store objects of this type in a std::vector<ClusterNode> as per the answer to this question error C2719: '_Val': formal parameter with __declspec(align('16')) won't be aligned?
As an alternative, I have tried using an array.
However, I cannot do
const int n = numNodes();
ClusterNode array [n];
Because the return value of a function is not considered a constant.
What other options do I have?
ClusterNode* array = new ClusterNode[n];- Alex Fstd::vectorno longer passes the element type by value, so non-overalignment of function parameters is no longer an issue. - Ben Voigt