I was going through great articles on C++ POD, Trivial and Standard Layout classes One property I haven't clearly understood about standard layout is the following:-
A standard layout has no base classes of the same type as the first
non-static data member
So the following will not be a Standard Layout as it has the first member same as the base class
struct NonStandardLayout3 : StandardLayout1 {
StandardLayout1 x; // first member cannot be of the same type as base
};
But performance-wise and property-wise how is the above struct any different than
struct StandardLayout5 : StandardLayout1 {
int x;
StandardLayout1 y; // can have members of base type if they're not the first
};
which is the correction of the one above this.