// AStd is a standard layout type struct AStd { int x; }; // BNonStd is NOT a standard layout type - not all members have the same access // control class BNonStd { int x; public: int y; }; // CNonStd is NOT a standard layout type - it has a virtual function class CNonStd { virtual void f(); }; // DNonStd is NOT a standard layout type - it has a virtual base class class DNonStd : public virtual AStd {}; // ENonStd is NOT a standard layout type - it has a data member of reference // type class ENonStd { int& xref; }; // FStd is a standard layout type - all data members are standard layout types class FStd { AStd a; }; // GNonStd is NOT a standard layout type - contains a non-standard-layout member class GNonStd { BNonStd b; }; // HStd is a standard layout type - its base class is a standard layout type struct HStd : AStd {}; // INonStd is NOT a standard layout type - its base class is not a standard // layout type struct INonStd : BNonStd {}; // JStd is a standard layout type struct JStd { static int x; }; // KStd is a standard layout type - base class has no non-static data members struct KStd : JStd {}; // LStd is a standard layout type - only one base class has non-static data // members struct LStd : AStd, JStd {}; // MNonStd is NOT a standard layout type - more than one base class with // non-static data members struct MNonStd : AStd, FStd {}; // Instantiations of NMaybeStd may or may not be standard layout types, // depending on the template parameter. template struct NMaybeStd { T x; }; // Instantiation NMaybeStd is a standard layout type NMaybeStd nmaybestd_astd; // Instantiation NMaybeStd is a standard layout type NMaybeStd nmaybestd_int; // Instantiation NMaybeStd is NOT a standard layout type NMaybeStd nmaybestd_bnonstd; // Instantiations of ONonStd cannot be standard layout types - regardless of the // template parameter's type - since not all members have the same access // control. template struct ONonStd { T x; private: T y; }; // Therefore instantiation ONonStd is NOT a standard layout type ONonStd ononstd_int;