The change I've suggested below should do it. This is explained in the "rationale" section of the manual. Robert Ramey Dieter Buys wrote:
Hi,
I am experiencing difficulties in getting the Boost serialization library to work. There seems to be an error related to object tracking, as I am getting BOOST_STATIC_ASSERTION_FAILURE<x>. I am trying to figure it out using the attached test code. The documentation claims I should be putting a BOOST_SERIALIZATION_TRACKING() macro in my file (presumably directly after my class definition). I did a full text search over the entire source of the library and nowhere did this preprocessor macro exist. There is a BOOST_CLASS_TRACKING() macro, which I tried putting in my source with tracking_never. That seems to have made no appreciable difference.
I have absolutely no idea what I am supposed to do. :( Any help would be appreciated.
Thanks, ~ Dieter Buys
#include <fstream>
#include
#include
#include #include #include class gps_position { private: friend class boost::serialization::access;
template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & degrees; ar & minutes; ar & seconds; }
int degrees; int minutes; float seconds;
public: gps_position() {}; gps_position(int d, int m, float s) : degrees(d), minutes(m), seconds(s) {} }; // BOOST_CLASS_TRACKING(gps_position, track_never)
int main(void) { std::ofstream ofs("serial.txt");
gps_position *g = new gps_position(35, 59, 24.567f); // const gps_position g(35, 59, 24.567f);
const gps_position * const g = new gps_position(35, 59, 24.567f);
{ boost::archive::text_oarchive oa(ofs); oa << g; } delete g;
gps_position *newg; // gps_position newg; { std::ifstream ifs("serial.txt", std::ios::binary); boost::archive::text_iarchive ia(ifs); ia >> newg; } delete newg;
return 0; }
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users