Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2006-07-15 00:14:00


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 <boost/shared_ptr.hpp>
>>
>> #include <boost/serialization/serialization.hpp>
>> #include <boost/serialization/tracking.hpp>
>> #include <boost/archive/text_oarchive.hpp>
>> #include <boost/archive/text_iarchive.hpp>
>>
>> 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_at_[hidden]
>> http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net