c++ - Using ` Eigen::aligned_allocator` on `std::vector` on classes containing Eigen types -


according eigen's documentation when creating std::vector "fixed-size vectorizable eigen types", eigen::aligned_allocator must used, e.g.:

std::vector<eigen::vector4f,eigen::aligned_allocator<eigen::vector4f> > myvector; 

i have class containing fixed-size eigen members, , std::vector of class, e.g.:

class myclass{ public:    eigen::vector2d v; } //... std::vector<myclass> myvector; std::vector<myclass*> myptrvector; 

question: am required use eigen::aligned_allocator vectors of classes containing eigen members (the same way vectors of eigen types directly)?

(i'm using visual studio 2013, if matters)

i believe answer yes.

the first sentence on page referenced says "... or classes having members of such types, requires taking following 2 steps

  • a 16-byte-aligned allocator must used. eigen provide 1 ready use: aligned_allocator.
  • if want use std::vector container, need #include . "

Comments