C'mon, c'mon ;-)Dominick Layfield wrote:Frank Birbacher wrote:I now noticed that the link I posted does not reference excatly what I meant to point at. Your code makes me think that you have not read what I wanted you to read. Here it goes. READ THIS: http://www.boost.org/libs/serialization/doc/rationale.html#trapWell, Hector may not have read this, but I did!
After I realized what the problem was, I found that it was rather common.And it seems that I have the same problem as him.
Perhaps the comments before the trap (code in the hpp file), should have a hyperlink.If I make the object I want to serialize a const, the (completely incomprehensible) compile error goes away. Any chance this could be added to a boost::serialization FAQ?you mean change the section named "rationale" to "FAQ"?
After reading the rationale, I saw that option (ii) allows me to postpone the fight (and I took it). What is more important is that the trap is there to remember it. Perhaps another solution would be to provide a base class for tracking objects. This way, instead of using the macro, one could derive from such class:It appears that I have a choice between (i) doing a const_cast on every object I want to save, and (ii) inserting a BOOST_CLASS_TRACKING(XXX, boost::serialization::track_never) line into my source code.
I wouldn't do that. C++ must allow me to shot myself if I'm not careful!!It seems to me that a cleaner, simpler (and less ambitious) solution would just be to make serialization of pointers an error.