Boost logo

Boost :

From: Dave Harris (brangdon_at_[hidden])
Date: 2002-11-22 16:07:35

In-Reply-To: <CEC3AC40-FB8D-11D6-B4E0-0003939BD83A_at_[hidden]>
On Tue, 19 Nov 2002 08:09:13 +0100 Matthias Troyer
(troyer_at_[hidden]) wrote:
> The only solution which comes to my mind is additional virtual
> functions for writing blocks of primitive types, which default to
> just calling the operator<< (>>) n times, but can be overridden
> by optimized functions for those archive types where optimized
> writes (load) are possible. Nothing else would need to be changed.
> What is objectionable in that approach?

Well, it is a lot of new virtual functions - one per type, almost doubling
the size of the archive interface. Is it worth it?

I am inclined to say it is, because I generally favour giving the archive
more information about what is going on. And efficiency matters,
especially for such a fundamental library as serialisation. It does not
lead to more work for serialisation users or for the archive implementers.
Still, it is a lot of new functions, and once added they can never be
taken away. It may be better to leave them out now, and add them in 12
months time, when we have had more experience with the library and its

Incidently, an alternative would be to add the new virtual functions but
remove the current ones, replacing them with non-virtual, inline versions
which just use a count of 1, eg:

    basic_oarchive &operator>>( basic_oarchive &ar, int x ) { &x, &x+1 );

This makes some overhead for the single-int case. I have no idea whether
the cost is worth the benefit in practice.

-- Dave Harris

Boost list run by bdawes at, gregod at, cpdaniel at, john at