I have two classes:
struct Base
{
int a;
};
template<typename T>
struct Derived : Base
{};
Are they layout compatible or not?
C++11 standard says ([class.mem]/16):
Two standard-layout struct (Clause 9) types are layout-compatible if they have the same number of non-static data members and corresponding non-static data members (in declaration order) have layout-compatible types.
But it also says ([class.derived]/8):
A base class subobject might have a layout (3.7) different from the layout of a most derived object of the same type.
And it confused me.
Note:
This check
static_assert(__is_layout_compatible(Base, Derived<int>), "");
passed on GodBolt (compiler - x86-64 gcc(trunk)).