I am trying to use the default serialization facilities with boost, but I didn't manage to serialize a complex vector. I tried this:
#include <fstream>
#include <complex>
#include <vector>
#include <boost/archive/text_oarchive.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/complex.hpp>
using namespace std;
typedef complex<double> type;
template<class Archive>
void serialize(Archive& ar, vector<type>& objs, const unsigned version) {
ar & objs;
}
int main(){
vector<type> r;
r.push_back(1.3);
r.push_back(12.12);
r.push_back(-31.05);
ofstream ofs("test.txt");
boost::archive::text_oarchive oa(ofs);
oa & r;
return 0;
}
which compiles fine but crashes on execution. Yet if I do
typedef double type
then everything works OK. I can't figure out a solution for that. Any help?
Thanks,
Jan