|
Boost Users : |
Subject: Re: [Boost-users] [serialization] serialization of a class as pointerand non-pointer
From: Robert Ramey (ramey_at_[hidden])
Date: 2011-10-10 12:40:12
Daniela Lambertz wrote:
> Now in the Serialization tutorial, I found that the adresses of
> objects with the tracking trait "track_selectively" are tracked if
> "an object of this type is anywhere in the program serialized through
> a pointer".
> Can this be the reason for my Energy-problem? If yes, is there a way
> to avoid this behaviour?
I believe you're speculation is correct here. The library includes the
(too) clever optimization that code to serialize/deserialize pointers
is used only if the type is serialized anywhere as a pointer. This will
lead to problems if the type is used in one program which serializes
the type via a pointer and the program is later changed (or a variant
is made) which doesn't do this. there are a couple of fixes for this:
a) don't do that - that is make sure all programs do it the same way.
b) use "serialization traits" to explicitly specify which level of
serialization
support you require. Specifically, over-ride the default "track
selectively"
with either "track always" or "track never".
This raises the very interesting and ultimately unresolvable dilema
about how a library should be designed. On one hand one get's what
we have now - something the produces the optimal solution 99% of the
time and a nasty situation 1% of the time or something that produces
a suboptimal solution 50% of the time but no nasty situations.
After having seen the library in usage for several years now - I'm amazed
how well it's worked. BUT, if I had nothing else to do, I see that
another pass - mostly on details such as this and a few other really
subtle issues - would be in order. It's hard to wind myself up for this
though. The first pass exhausted me.
Robert Ramey
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