Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2004-04-21 00:27:45


I just realized I skipped something

Vladimir Prus wrote:

>
> ** Custom archive creation **
>
> I've tried to create a custom archive class (in fact,
> polymorphic_oarchive),
> and got some comments.
>

> - Documentation says the derived class must provide operator<< and method
> 'load'. It also says there common_iarchive::operator<<. I wonder why the
> derived class should provide operator<<. Can't base operator call 'load'
> directly?
>

common_iarchive has no operator<<

'load' is called by the library to load primitives - its generally not
called by the << operator unless one wants to bypass the serialization
system entirely.

Perhaps, my usage of load_override was confusion. I use load_override in
order to work around the lack of partial template function ordering. Were
it not for this, load_override would not exist. This is an implementation
artifact. Load on the other hand is the function used to load primitives.

> - Even if not, why derived operator<< should have
>
> return * This();
>
> not plain "return *this"? After all, we're in most derived object
>

No we are not.

The class hierarchy is

common_iarchive
   base_text_oarchive
       text_oarchive_impl
           text_oarchive

in my archives, the operator<< is a member of base_text_oarchive. If I want
the << operator to return a reference to a text_oarchive NOT
basae_text_oarchive.

The archives included are models of the trivial_archive. However, the
desire to factor things out in a convenient way makes them less transparent
than I would prefer.

Robert Ramey


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