名前付き要件: StandardLayoutType
提供: cppreference.com
型が標準レイアウト型であることを指定します。 標準レイアウト型は他のプログラミング言語で書かれたコードとやりとりするために有用です。
ノート: 標準はこの名前を持つ名前付き要件を定義していません。 これはコア言語によって定義される型カテゴリです。 これは一貫性のためだけに名前付き要件としてここに含まれています。
目次 |
[編集] 要件
- すべての非静的データメンバが同じアクセス制御を持つ。
- 仮想関数または仮想基底クラスを持たない。
- 参照型の非静的データメンバを持たない。
- すべての非静的データメンバおよび基底クラスがそれ自体標準レイアウト型である。
|
(C++14未満) |
struct Q {}; struct S : Q { }; struct T : Q { }; struct U : S, T { }; // not a standard-layout class: two base class subobjects of type Q
struct B { int i; }; // standard-layout class struct C : B { }; // standard-layout class struct D : C { }; // standard-layout class struct E : D { char : 4; }; // not a standard-layout class
|
(C++14以上) |
[編集] 性質
標準レイアウトを参照してください。
[編集] 欠陥報告
以下の動作変更欠陥報告は以前に発行された C++ 標準に遡って適用されました。
DR | 適用先 | 発行時の動作 | 正しい動作 |
---|---|---|---|
CWG 1672 | C++14 | first non-static data member rule ignored existence of empty base classes | first non-static data member rule made recursive |
CWG 1813 | C++14 | class with a member defined in an indirect base wasn't technically standard-layout | all member declarations must be in the same class |
CWG 2120 | C++14 | array as first member wasn't considered when comparing the first element type with type of a base | array members are considered |
[編集] 関連項目
(C++11) |
型が標準レイアウト型かどうか調べます (クラステンプレート) |