2015-07-20 72 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容器時不需要特別小心。

(重點煤礦)