Should work without problem.
make sure you're including
Hello,
I have a Class A with string attributes that I serialize in XML format: Class A { public: string _nom; string _prenom; template<class Archive> void serialize(Archive& ar, const unsigned in version){ ar & boost::serialization::make_nvp("Nom", _nom); ar & boost::serialization::make_nvp("Prenom", _prenom); } }
The object is correctly saved using this code:
A _a;
void save() const { ... oTextArchive::xml_oarchive oTextArchive(ofile); oTextArchive << make_nvp("A", _a); ... }
But I want to reload the object, the A attributes aren't updated and keep the previous values:
void load() { ... iTextArchive::xml_oarchive iTextArchive(ifile); iTextArchive >> make_nvp("A", _a); ... }
The only way I found to reload my object is to use an temporary object: void load() { ... A _tmp; iTextArchive::xml_oarchive iTextArchive(ifile); iTextArchive >> make_nvp("A", _tmp); _a = _tmp; ... }
Why can't I update the object directly?
Thanks for your help.