Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-10-03 06:15:11


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.

Actually, I was under impression that 'load'/'save' pair is supposed to
handle the case when no default ctor is available, but now I see they
presume object already exists. So I can't use placement new even in 'load'
function.

Robert, could you clarify if default ctor is ineeded required in all cases?

- Volodya


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