Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-10-01 12:16:34


Vladimir Prus <ghost_at_[hidden]> writes:

> David Abrahams wrote:
>> Samuel Krempp <krempp_at_[hidden]> writes:
>> > If I got it right, Robert is reluctant to have deserialization require
>> > default-constructability, even private
>>
>> I certainly agree that it's a nasty constraint. I think I can see
>> only one way to achieve non-intrusive deserialization in portable C++:
>> the deserialization function gets an address into which the object
>> will be constructed with placement new.
>
> 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

-- 
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