Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2005-10-12 16:50:26


From: "Robert Kawulak" <kawulak_at_[hidden]>
>
> here the problem begins - with some compilers inheriting from classes with
> no members doesn't change the sizeof of object, while with others it does.
> For instance:
>
> struct e { };
>
> struct f : public e { };
>
> // A class inherited from empty base classes, with a char member
> struct g : public f {
> char c;
> };
>
> // Same as g but not inherited
> struct h {
> char c;
> };
>
> The sizeof for e, f, g and h is, respectively:
> with gcc & MSVC: 1, 1, 1, 1
> DMC: 1, 1, 2, 1
> Borland: 8, 8, 16, 1

You should assume a quality compiler that provides the EBO for
the general case. For Borland, you can reduce the problem by
conditionally inserting a char (not bool!) data member in the
policies.

-- 
Rob Stewart                           stewart_at_[hidden]
Software Engineer                     http://www.sig.com
Susquehanna International Group, LLP  using std::disclaimer;

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