Are the class members of this simple class continous in memory?
class A{
A(){ /* somecode */}
~A();
Eigen::Matrix<5,1,double> a;
Eigen::Matrix<9,1,double> b;
};
std::vector<A> vec(10);
char * p = interprete_cast<char*>(&vec[0]);
// the pointer p can now continously access all "a" and "b" in continous order -> (a,b,...,a,b)
// For example write all data to a binary file!
file.write( p, sizeof(A)*vec.size() )
In other posts there was something mentioned about #pragma pack
and so on?
Is this needed here? Link
or is it better to pack the members into a struct
Thanks alot :-)