C++ "vector of vectors"

C++ "vector of vectors"

本文关键字:vectors of vector C++      更新时间:2023-10-16

我必须创建一个包含Eigen::Vector2d向量的std::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

请告诉我是否有遗漏的信息,以便找到问题的根源。

您可能没有阅读文档:

在固定大小的可向量化特征类型或具有此类类型成员的类上使用STL容器需要执行以下两个步骤:

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

  • 如果你想使用std::vector容器,你需要#include

这些问题只出现在固定大小的可向量化特征类型和具有这样的特征对象作为成员的结构中。对于其他特征类型,如Vector3f或MatrixXd,在使用STL容器时不需要特别注意。

(强调我的)