I am trying to serialize/deserialize an Armadillo colvec object using Boost. The colvec is a column vector with a few different sizes e.g. it can have 2 rows for 2d vector, 3 rows for 3d vector and I'm also using other specific vector sizes in the code.
I am not sure how to deal with the serialisation for the colvec type in boost when the number of rows in the colvec is unknown during deserialization.
For example to serialise, I might include the following:-
namespace boost
{
namespace serialization
{
template<class Archive>
void serialize(Archive& archive, colvec& vector, unsigned int)
{
for (int i=0; i<vector.size(); i++)
{
archive& vector[i];
}
}
}
}
This will serialise a colvec with any number of rows. However, when this code is run during "de-serialization" vector will be a colvec of size()==0 e.g. the required number of rows will be unknown.
I was wondering what would be the best way to handle this.
I may be mistaken in my understanding. I am new to both Armadillo and Boost.