Boost logo

Boost :

From: Persson Jonas (Jonas.Persson_at_[hidden])
Date: 2002-02-28 08:49:32


> -----Original Message-----
> From: quendezus [mailto:quendez_at_[hidden]]
> Sent: Thursday, February 28, 2002 9:56 AM
> To: boost_at_[hidden]
> Subject: [boost] Re: Serialization (Persistence) library draft
> submission
>
>
> --- In boost_at_y..., "David Abrahams" <david.abrahams_at_r...> wrote:
> >
> > There are much worse problems with operator>>() than that one, IMO.
> How do
> > you unserialize an object with no default constructor?
> >
> > -Dave
> >
>
> Do you think deserialization of objects with no default constructor
> should be a requirement?
>
> Sylvain

Serialization with a default constructor requirement would be almost
useless.

I often have the requirement that all objects must be valid at
all times. That cannot normally be done with default construcion.
Just look at the gps_position class in the example. It would not be
acceptable in production code.

What would be needed is a deserialization constructor and a way to get the
next serialized object witout using operator >>

class gps_position {
  ...
  gps_position(::boost::iarchive &ar)
    : degrees(ar.get<int>())
    , minutes(ar.get<int>())
    , seconds(ar.get<float>())
};

I dont think that would be much of a problem to add?

It would also solve the problem with references and const members,
which I think _is_ part of the object state and thus is important so save.

        / Jonas


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk