Boost logo

Boost Users :

From: Thomas Matelich (matelich_at_[hidden])
Date: 2006-09-13 11:07:50


On 9/13/06, David Abrahams <dave_at_[hidden]> wrote:
> Jeff Garland <jeff_at_[hidden]> writes:
>
> > Loïc Joly wrote:
> >> Jeff Garland a écrit :
> >
> >>> Oliver is correct -- serialization does not require default constructors for
> >>> the types. It does require a constructed object prior to reading in the data.
> >>
> >> Yes, you are right. My mistake.
> >>
> >> What I meant is that for deserialisation, you still have a two phases
> >> construction: First, build your object with any mean available (if your
> >> object have only constructors with non-default parameters, this will
> >> probably imply building them with dummy parameters), then, in a second
> >> phase, override the member values by the serialized version.
> >
> > Yep.
>
> Nope. Sorry to be blunt, but I just want to make absolutely sure this
> isn't missed:
>
> http://boost.org/libs/serialization/doc/serialization.html#constructors:
>
> template<class Archive>
> inline void load_construct_data(
> Archive & ar, my_class * t, const unsigned int file_version
> ){
> // retrieve data from archive required to construct new instance
> int m;
> ar >> m;
> // invoke inplace constructor to initialize instance of my_class
> ::new(t)my_class(m);
> }
>
> One phase construction.
>

I poked around in the link you posted, but I don't see any examples of
a my_class getting serialized into. Where does t come from? IOW, how
do I call this without passing dummy information into a my_class
object? I'm sure I'm missing something, but all I can envision is a
reinterpret_cast of a void*/malloc. Or two one-phase constructions.


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