Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2004-09-10 05:03:50

> Well, compressed_pair applies to a pair and compressed_member applies
> memberwise. In a situation where you have more than two members
> compressed_member may compact better.
> Consider this situation:
> struct A {};
> struct B {};
> struct C
> : compressed_member<A>
> , compressed_member<A, 1>
> , compressed_member<B, 1>
> , compressed_member<B, 1>
> {
> };
> Here, each A gets its address but the Bs can share those same addresses. I
> think applying the optimization memberwise may scale better for arbitrary
> tuples.

Except that most compilers don't implement the empty-base-optimisation when
there is multiple inheritance taking place, in fact for at least one compile
(Borland's) this is a serious dis-optimisation, with 8-bytes per base class
getting added!

The compressed_pair way would be:

struct C
            non_empty_type> > m_data;

and of course this way struct C doesn't have any "accidental" base classes,
not even private ones.


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