Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2002-05-02 08:58:23

On Wednesday, May 1, 2002, at 11:46 PM, Andrei Alexandrescu wrote:

> Also, I saw a very similar trick,
> if not the very same trick (can't check now, I'm on a very slow
> connection) in compressed_pair.
> The idea is to use derivation only for those policies that are
> nonempty, and
> to simply not derive at all from policies that are empty.

Dave already pointed this out, but I wanted to confirm: compressed_pair
doesn't work this way. compressed_pair derives from empty classes and
contains non-empty types as members.

We thought about building compressed_pair the way you describe, but
because of the lack of running the empty class constructors and
destructors decided it was not a good idea. A constructor or destructor
of an empty class could still effect the state of a program (class
static data or a global variable) and thus needs to behave as if it is a

This is not to say that the technique you outlined would not be suitable
for a smart pointer. But the interface (docs) should state:
constructors/destructors of empty policies are not allowed to do


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