I have a class A like this:
struct V {
virtual void f() = 0;
};
struct A {
int data;
};
struct B : public A , public V {
void f() override {}
};
MSVC gives me sizeof(A) == 4
and sizeof(B) == 16
on a 64 bit build instead of 12 (sizeof(void*) + sizeof(A)
) - so there is a 4 byte padding. Is there a way to get that padding? perhaps with some trait?
The reason I need this is to do an assert like this:
static_assert(sizeof(B) == sizeof(A) + std::is_polymorphic<camera>::value * sizeof(void*));
Meaning that I want to ensure that all data is in the base class, but B should be able to be polymorphic by inheriting from some interface... No new members shall be added to B but it should be allowed to be polymorphic. If I had 2 integers in A
there would be 0 padding at the end of B
...