|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-06-24 08:24:47
Vladimir Prus <ghost_at_[hidden]> writes:
> >
> > Its very easy to write
> > for(...{
> > X x = *it; // create a copy of
> > ar << x
> > }
> >
> > all the x's are at the same address so if they happen to be tracked
> > because
> > a pointer to some X in serialized somewhere in the program, then the
> > subsequent copies would be supprsed by tracking.
>
> What does "the subsequence copies would be supressed by tracking"? Are you
> saing that only one 'X' will be stored in archive?
Yes, if (as is highly likely) the x happens to have the same address
in each iteration of the loop. To reconstruct object graphs correctly
(that's what tracking is for), you need to do it that way.
> And what will happen duing deserialization. Will you load just one
> 'X' object, and then for each iteration of deserialization loop,
> make a copy of it?
Surely it depends what the deserialization loop looks like, but the
serialization library itself won't make any copies: it will return a
reference or pointer to that same object each time.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk