Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2005-10-12 12:23:36


On 10/12/2005 10:52 AM, Robert Kawulak wrote:
[snip]
> current policies). Is there any workaround for this (IOW is there any way to
> make inheritance of empty classes not make sizeof grow)? Of course
> composition instead of inheritance is a no-go, because it always makes

By "composition" (of f, for example) do you mean:

// A class inherited from empty base classes, with a char member
struct g {
   f a_f;
   char c;
};

?

> sizeof bigger. Is it worth to add this functionality to the constrained type
> even though with some compilers its size will grow?

The policy_ptr library in sandbox used to have something that could
test whether a base class was empty and eliminate it from the
inheritance. I think the template class used was already somewhere
in boost. Looking...

Yes. A copy is at:

http://cvs.sourceforge.net/viewcvs.py/boost-sandbox/boost-sandbox/boost/managed_ptr/optimally_inherit.hpp

HTH.


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