Robert Ramey wrote:
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#trap
      
Well, Hector may not have read this, but I did!
C'mon, c'mon  ;-)
  And it seems that I
have the same problem as him.
After I realized what the problem was, I found that it was rather common.
  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"?
  
Perhaps the comments before the trap (code in the hpp file), should have a hyperlink.
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. 
    
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:

class MyClass : private boost::serialization::trackme

And this "trackme" class could have parameters in the constructor to say whether it should be tracked:

MyClass()::MyClass()
: boost::serialization::trackme(never)
{}

or

MyClass()::MyClass()
: boost::serialization::trackme(selectively)
{}

etc ..

This solution would be in addition to the const-reference and BOOST_CLASS_TRACKING ones.
It seems to me that a cleaner, simpler (and less ambitious) solution
would just be to make serialization of pointers an error.
    
I wouldn't do that. C++ must allow me to shot myself if I'm not careful!!



Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more.