2015-07-20 69 views
-2

我必须创建一个std::vector,其中包含Eigen::Vector2d的向量。这是我做了声明:C++“vector of vector”

std::vector< std::vector<Eigen::Vector2d> > markingsPointSets; 

,我尝试推回我喜欢创造一些元素:

Eigen::Vector2d firstMarkingPoint(markingPointA[0] + AB_perp[0] * .15, markingPointA[1] + AB_perp[1] * .15); // Don't mind to the value of this variable :p 

markingsPointSets.at(i).push_back(firstMarkingPoint); 

,但是这给了我:

error c2719 formal parameter with __declspec(align('16')) won't be aligned 

请告诉我如果有一些缺失的信息可以找到这个问题的根源。

+0

欢迎StackOverflow上。只是疯狂的猜测,但是'Vector2d'声明了特定的对齐设置,当它被放到'std :: vector'中时可能无法保证? –

+0

请参阅[此问题](http://stackoverflow.com/questions/25300116/directxxmmatrix-error-c2719-declspecalign16-wont-be-aligned)。 –

回答

2

你可能没看过documentation

使用STL容器上固定大小的量化的本征类型,或具有此类型的成员类别,需要采取以下两个步骤:

  • 必须使用16字节对齐的分配器。 Eigen提供了一个可供使用的:aligned_allocator。

  • 如果你想使用std::vector容器,你需要#include < Eigen/StdVector>。仅与固定大小的向量化的本征类型和具有这种本征对象作为成员的结构出现

这些问题。对于其他特征类型,如Vector3f或MatrixXd,在使用STL容器时不需要特别小心。

(重点煤矿)