From: David Abrahams (dave_at_[hidden])
Date: 2003-10-03 18:03:52
Vladimir Prus <ghost_at_[hidden]> writes:
> David Abrahams wrote:
>>> I certainly miss something. You still have to either pass ctor parameters
>>> when using placement new, or require the serialized type to have default
>>> ctor. Am I wrong?
>> The serialization function writes the information neccessary to
>> reconstruct the ctor args.
>> The deserialization function deserializes that information from the stream
>> and then does the in-place construction.
>> This design is inspired by Python's __getinitargs__ interface to the
>> pickle module. http://www.python.org/doc/current/lib/module-pickle.html
> That's not a general solution, I'm afraid. In the case I had, not all
> arguments to original ctor call are stored as member variables, and so not
> all can be saved. To work around it, I'd have to add public ctor which
> allows to specify the values of all the fields.
I'm not sure I understand your case completely, but just to clarify: I wasn't
suggesting that the deserialization function should *only* call the
constructor. It is free to do whatever other manipulations are
neccessary to get the object into the desired state.
If there's really no way to do that using the class' public interface,
I guess I'm OK with the idea that intrusiveness (e.g. a friend
declaration) is required if you want to serialize instances of the
-- 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