From: Robert Ramey (ramey_at_[hidden])
Date: 2003-09-29 10:44:50
Vladimir Prus wrote:
>The serialization library likes if serialized classes have default
>constructor. Seems like it's possible to avoid declaring default ctor with
>separate "load"/"save" functions, but this is not really necessary: I can put
>default ctor in private section, and everything works ok.
>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.
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. Your example:
> vector<V> v;
> oa << v;
creates an empty vector of objects of type v. A slightly more realistic example
oa << v;
This cases would break even before considering the serialization.
On the other hand the following example is concievable
oa << v;
which I believe fairly illustrates the situtation which concerns you.
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.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk