|
Boost Users : |
From: Hector C. (hhcalderon_at_[hidden])
Date: 2007-08-18 15:28:19
Robert Ramey wrote:
Dominick Layfield wrote:
Frank Birbacher wrote:
I now noticed that the link I posted does not reference excatly whatI meant to point at. Your code makes me think that you have not readwhat 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 Ihave the same problem as him.
After I realized what the problem was, I found that it was rathercommon.
If I make the object I want toserialize a const, the (completely incomprehensible) compile errorgoes away. Any chance this could be added to a boost::serializationFAQ?
you mean change the section named "rationale" to "FAQ"?
Perhaps the comments before the trap (code in the hpp file), shouldhave a hyperlink.
It appears that I have a choice between (i) doing a const_cast onevery object I want to save, and (ii) inserting aBOOST_CLASS_TRACKING(XXX, boost::serialization::track_never) lineinto my source code.
After reading the rationale, I saw that option (ii) allows me topostpone the fight (and I took it). What is more important is that thetrap is there to remember it. Perhaps another solution would be toprovide a base class for tracking objects. This way, instead of usingthe macro, one could derive from such class:
class MyClass : private boost::serialization::trackme
And this "trackme" class could have parameters in the constructor tosay 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 andBOOST_CLASS_TRACKING ones.
It seems to me that a cleaner, simpler (and less ambitious) solutionwould just be to make serialization of pointers an error.
I wouldn't do that. C++ must allow me to shot myself if I'm notcareful!!
---------------------------------
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more.
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