Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-04-18 20:32:42


----- Original Message -----
From: "Alex Rosenberg" <alexr_at_[hidden]>

> While I appreciate the flexibility of policy-based designs, I have
serious
> reservations about the overhead that comes with using policies as base
> classes with multiple inheritance.
>
> Unfortunately, empty base classes aren't free.

In theory, they are. Just not in practice.

> Most smart pointers want to
> be very small and low overhead.
>
> Perhaps a C++0x extension could fix this:
>
> class foo : public register empty_base { ... };
>
> Here I'm using "register" since it already indicates that the address
cannot
> be taken, but any suitable indicator could be used to resolve this.

Implementations are already allowed to optimize away empty bases, and
some do. The ones that don't are mostly just stuck with preserving
binary compatibility. The only purpose your identifier would serve would
be to make sure that newly-declared classes with multiple empty bases
didn't have a binary compatibility problem, since older classes didn't
allow the syntax. I doubt anyone would be willing to uglify the language
for this reason.

My proposal is to use a single composite policies base class to avoid
the MI overhead implicit in quite a few compilers.

-Dave


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