Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2004-01-22 12:23:17


Vladimir Prus wrote

>> a) it would require exported strings to always be included in archives
>> regardless of whether or not they are strictly necessary. - thus
>> provoking howls from those for whom maximum speed is a main
>> consideration.

>Is it really true?

I'm pretty sure some boost member or other will howl if anything less
the maximum efficiency is permitted. And they might even be right.
I believe that the serialization libary might be useful for marshalling
data for remote procedure calls. In that scenario - the common
case would be lots of little serializations - rather than one large
one as is the more common case. In such a case, efficiency
considerations would be judged differently.

>Consider:

> B* b = get_b();
> oa << b;

> // and later

> B* b;
> ia >> b;

Hmm I believe the above code should work as expected regardless
of the true type of b. That certainly is my intention.

>If 'get_b()' decides to return really 'B' and not some derived class, you
>don't save identification and proper restoring depends on order of saving.
>So, if I change loading code to

> ia.template register_type<A>();
> B* b;
> ia >> b;

>I'll read pointer of class 'A'. See attachment for testcase.

In addition so save/load operations, explicit registrations
in save/load archives must also be in sync. It key to
how the system works. So the above would have to
be formulated with register in both save and load or
neither save and load. If this is done, no problems
occur.

So. I would consider this an erroneas usage of the library.

>I don't expect that saving *object* of type A and loading *object* of type B
>should ever work, nor that it's diagnosed.

Someday I would like to see this diagnosed.

In general, the serialization library relies on save/load being
closely in sync. Its a key feature/constraint. Its incumbent upon
the programmer to maintain this. There is help available (& operator)
and if there were interest its possible to provide more but
this is a fundemental requirement. My presonal taste
is to make save/load functions syncronised by observation. That
is I always maintain a syncronised pair so I can visually
confirm that they are in sync. Its the best I can do for now.

Robert Ramey


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