Boost logo

Boost :

From: Persson Jonas (Jonas.Persson_at_[hidden])
Date: 2002-02-28 09:31:47

> -----Original Message-----
> From: Peter Dimov [mailto:pdimov_at_[hidden]]
> Sent: Thursday, February 28, 2002 2:57 PM
> To: boost_at_[hidden]
> Subject: Re: [boost] Re: Serialization (Persistence) library draft
> submission
> From: "Persson Jonas" <Jonas.Persson_at_[hidden]>
> > Serialization with a default constructor requirement would be almost
> > useless.
> I find your arguments sound in general but this statement is untrue.

It would mean that if I would add serialization to my project I would need
through all my classes and add a defult constructor and also remove const
of the data members I need to save the state of. And then add contracts
error handling to ensure proper use (wich was previously guaranteed by
A lot of unnessessary work that would reduce the robustness of my program.
It would
at least make me think twice before I added it.

> > What would be needed is a deserialization constructor and a
> way to get the
> > next serialized object witout using operator >>
> You can't add a serialization constructor to builtins, enums,
> std:: classes,
> and third party classes.

True, but would I need to? They already has default construction.

but maybe we should use a trait to select a proper implementation
of get

template<typename T>
T get(::boost::iarchive &ar) {
  T t;
  ar >> t;
  return t;

for default constructibel and:

template<typename T>
T get(::boost::iarchive &ar) {
  return T(ar);

for deserialize constructible.

        / Jonas

Boost list run by bdawes at, gregod at, cpdaniel at, john at