I'm trying to serialize Eigen's matrix. So that I can serialize a more complex object. I'm using Matrix as a base class and include the serialization in the derived class. I'm confused on how to address Matrix.data(), which returns a c-style array (if i'm correct). This is my attempt:
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
template < class TEigenMatrix>
class VariableType : public TEigenMatrix {
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & this.data();
}
public:
};
I would like to use it as a "wrapper" :
VariableType<Matrix<double,3,1>> serializableVector;
in place of
Matrix<double,3,1> vector;