-1

I have to create a std::vector containing vectors of Eigen::Vector2d. This is how I do the declaration :

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

and I try to push back some elements I created like that :

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);

but this gives me :

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

Please tell me if there are some missing information to find the source of this problem.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • Welcome to StackOverflow. Just a wild guess, but is `Vector2d` declared with specific alignment settings that might not be guaranteed when putting it into a `std::vector`? – Remy Lebeau Jul 20 '15 at 23:43
  • See [this question](http://stackoverflow.com/questions/25300116/directxxmmatrix-error-c2719-declspecalign16-wont-be-aligned). – Beta Carotin Jul 20 '15 at 23:47

1 Answers1

3

You probably have not read the documentation:

Using STL containers on fixed-size vectorizable Eigen types, or classes having members of such types, requires taking the following two steps:

  • A 16-byte-aligned allocator must be used. Eigen does provide one ready for use: aligned_allocator.

  • If you want to use the std::vector container, you need to #include < Eigen/StdVector >.

These issues arise only with fixed-size vectorizable Eigen types and structures having such Eigen objects as member. For other Eigen types, such as Vector3f or MatrixXd, no special care is needed when using STL containers.

(emphasis mine)

Community
  • 1
  • 1
Tas
  • 7,023
  • 3
  • 36
  • 51