C
Chris Fairles
I recently implemented c++0x variants of tuple to take advantage of
ECBO and then implemented unique_ptr using a tuple to hold the pointer
- deleter pair so that sizeof(unique_ptr<int>) == sizeof(int*).
It then came to my attention that its a lot of hoops to jump through
just to take advantage of ECBO. I'm wondering whats preventing
something like :
struct SomeEmptyType {void f(){}};
struct A {
SomeEmptyType t;
int * i;
};
from having a sizeof(int*) and not sizeof(int*) + 1 + padding to align
with next boundary?
I know the standard says that "Complete objects and member subobjects
of class type shall have nonzero size." and "Base class subobjects are
not so constrained." but why? Is there some C-compatibility issue?
I think "A a; reinterpret_cast<SomeEmptyType*>(&a)->f();" could still
be well formed even if t had no storage or is this not possible to do
for compiler implementors?
ECBO and then implemented unique_ptr using a tuple to hold the pointer
- deleter pair so that sizeof(unique_ptr<int>) == sizeof(int*).
It then came to my attention that its a lot of hoops to jump through
just to take advantage of ECBO. I'm wondering whats preventing
something like :
struct SomeEmptyType {void f(){}};
struct A {
SomeEmptyType t;
int * i;
};
from having a sizeof(int*) and not sizeof(int*) + 1 + padding to align
with next boundary?
I know the standard says that "Complete objects and member subobjects
of class type shall have nonzero size." and "Base class subobjects are
not so constrained." but why? Is there some C-compatibility issue?
I think "A a; reinterpret_cast<SomeEmptyType*>(&a)->f();" could still
be well formed even if t had no storage or is this not possible to do
for compiler implementors?