Here's the answer, why is it 8-byte: Why does empty base class optimization not work?
The solution is to combine all the base classes. To be elegant, we could write like this:
template <class Base = empty_base> class A1 : public Base {}; template <class Base = empty_base> class A2 : public Base {}; template <class Base =empty_base> class A3 : public Base {}; class C : public A1<A2<A3> > { int c; };
You can find more code in this template in "boost / operator.hpp"
source share