Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-09-30 00:52:04


Robert Ramey wrote:

>>The problem arises when deserializing vector of classes which private
>>default ctor. Even though class has "friend class
>>boost::serialization::access", I get compile errors.
>
> <smip ...>
>
> Your example intrigued me and raised an number of interesting questions.
> I tried to compile your program and got the same result on my system
> then started to think about it.
>
> The idea that one might have a private default constructor has never
> occurred to me.

Interesting! When I was experimenting with serialization of pointers, I
failed to declare default ctor, got error, and immediately though "why
don't add it to private section". It worked, and I though it was an
excellent design. If it's not intentional, it's still very good ;-)

> Your example:
>
>> vector<V> v;
>> oa << v;
>
> creates an empty vector of objects of type v. A slightly more realistic
> example would be
>
> vector<V> v;
> V v_element;
> v.push_back(v_element);
> oa << v;
>
> This cases would break even before considering the serialization.
> On the other hand the following example is concievable
>
> vector<V> v;
> V v_element(0)
> v.push_back(v_element);
> oa << v;
>
> which I believe fairly illustrates the situtation which concerns you.

Yes, that's exactly what I wanted.

> The situation of non default constructors is already addressed
> for objects serialized through pointers. But I've failed to
> address it for other objects.
>
> I will consider the best way of handling this.

Thanks!

- Volodya


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