
Chris Yuen wrote:
Robert,
It is a fundamental concept that saving data to an archive should not alter the data. In many cases this is detected at compile time and a warning is issued. As noted in another post, you might snooker the system by suppressing tracking,
I don't really understand. Why does the tracking has something to do with the object's lifetime? Doesn't boost::serialization has all the information it needs (tracking info, data, etc.) when I call "oa << base_ptr"? Isn't it possible to just write out everything to the stream?
IIUC, tracked objects have their addresses place in a map, so that subsequent serialized pointers of the same value are serialized as a reference to the original object at that address, rather than serializing another copy of the object. Your code makes it possible for base_ptr to have the same value on subsequent calls to Serializer::serialize, but for different types. Could be that seeing to different types with the same address is confusing things. I could be that if you only serialized Strings or Doubles, that you would not "seg fault", but you'd only see N of the first object serialized. HTH, Jeff