【发布时间】:2012-07-03 06:24:07
【问题描述】:
我正在阅读C++ POD, Trivial and Standard Layout classes 上的精彩文章 关于标准布局,我还没有清楚了解的一个属性如下:-
A standard layout has no base classes of the same type as the first
non-static data member
因此以下将不是标准布局,因为它的第一个成员与基类相同
struct NonStandardLayout3 : StandardLayout1 {
StandardLayout1 x; // first member cannot be of the same type as base
};
但是在性能方面和属性方面,上述结构有何不同
struct StandardLayout5 : StandardLayout1 {
int x;
StandardLayout1 y; // can have members of base type if they're not the first
};
这是对上面那个的更正。
【问题讨论】:
标签: c++ c++11 standard-layout