Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2003-09-30 17:09:38


wrote:
> It seems to me that the right way to get a Foo out of a stream is not
> Foo foo;
> i >> foo;
> but rather
> Foo foo( i );
Dave Harris wrote:

>> You construct a foo based on the data in the input stream.

>Agreed, but in practice this can make it hard to implement Foo in a
>flexible way.

> class Foo {
> Member member1;
> Member member2;
> public:
> Foo( archive &ar ) : member1(ar), member2(ar) {
> }
> };

>Looks good, but how do we add versioning and XML?

>-- , Nottingham, UK

This issue was raised during last november's review.

I had previously rejected this idea for the following reasons

a) The above method doesn't work if the object is already created.
Now we require just one function (down from two) so
specify the serialization of a class. If we implemented
the above, we would have to add a special constructor.
So we would have to maintain two different ways of
doning the samething.

b) it lacked symetry

c) I saw no way to accomdate versioning.

d) I wouldn't work for non-intrusive serialization

On the other hand, it did eliminate certain copying of
compared to the current method.

By the way, I believe it might be possible with the
current method to use such a method by specification
of non-intrusive serialization. Use BOOST_SERIALIZATION_SPLIT_FREE
to declare save/load functions which take an archive as an argument
and then invoke the constructor method.

If I had nothing else to do, I might make an example and add
it to the manual.

Robert Ramey


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