Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2006-09-13 10:16:42


Loïc Joly <loic.joly_at_[hidden]> writes:

> Jeff Garland a écrit :
>> Loïc Joly wrote:
>>
>>>Oliver Mutz a écrit :
>>>
>>>>Loïc Joly wrote:
>>>>
>>>>
>>>>>Nat Goodspeed a écrit :
>>>>>
>>>>>
>>>>>>I haven't yet worked with a serialization framework smart enough to
>>>>>>consider constructor arguments. (I haven't yet worked with the Boost
>>>>>>Serialization library, either; forgive me if this is already a solved
>>>>>>problem.)
>>>>>
>>>>>Boost::serialization requires a constructor with no arguments.
>>>>
>>>>That's not right I'm afraid. See the "Non-Default Constructors" part of the
>>>>serialization library documentation for details.
>>>
>>>This pertains to deserializing pointers to instances of classes with no
>>>default constructor. Is does not mean anything concerning
>>>deserialization of instances. Those need to be constructed before being
>>>deserialized to.
>>
>>
>> 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.

No. Please see

http://boost.org/libs/serialization/doc/serialization.html#constructors

That's one phase.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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