Memory model
| General topics | ||||||||||||||||
| Flow control | ||||||||||||||||
| Conditional execution statements | ||||||||||||||||
| Iteration statements (loops) | ||||||||||||||||
|
||||||||||||||||
| Jump statements | ||||||||||||||||
| Functions | ||||||||||||||||
| Function declaration | ||||||||||||||||
| Lambda function expression | ||||||||||||||||
inline
specifier
|
||||||||||||||||
| Dynamic exception specifications ( until C++17* ) | ||||||||||||||||
noexcept
specifier
(C++11)
|
||||||||||||||||
| Exceptions | ||||||||||||||||
| Namespaces | ||||||||||||||||
| Types | ||||||||||||||||
| Specifiers | ||||||||||||||||
|
||||||||||||||||
| Storage duration specifiers | ||||||||||||||||
| Initialization | ||||||||||||||||
| Expressions | ||||||||||||||||
| Alternative representations | ||||||||||||||||
| Literals | ||||||||||||||||
| Boolean - Integer - Floating-point | ||||||||||||||||
| Character - String - nullptr (C++11) | ||||||||||||||||
| User-defined (C++11) | ||||||||||||||||
| Utilities | ||||||||||||||||
| Attributes (C++11) | ||||||||||||||||
| Types | ||||||||||||||||
typedef
declaration
|
||||||||||||||||
| Type alias declaration (C++11) | ||||||||||||||||
| Casts | ||||||||||||||||
| Memory allocation | ||||||||||||||||
| Classes | ||||||||||||||||
| Class-specific function properties | ||||||||||||||||
|
||||||||||||||||
| Special member functions | ||||||||||||||||
|
||||||||||||||||
| Templates | ||||||||||||||||
| Miscellaneous | ||||||||||||||||
C++抽象機械の目的において、コンピュータメモリストレージのセマンティクスを定義します。
C++プログラムが利用可能なメモリは、1つ以上の連続した byte のシーケンスです。メモリ内の各byteは一意の address を持ちます。
目次 |
バイト
バイトは、メモリの最小アドレス可能単位です。連続したビット列として定義され、十分な大きさを持ち
-
任意の
UTF-8コードユニットの値(256の異なる値)および
|
(C++23まで) |
|
(C++23以降) |
Cと同様に、C++は8ビット以上のサイズのバイトをサポートしています。
types char 、 unsigned char 、および signed char は、ストレージと value representation の両方に1バイトを使用します。バイト内のビット数は CHAR_BIT または std:: numeric_limits < unsigned char > :: digits でアクセス可能です。
メモリ位置
memory location とは、 object representation が占有する記憶域であり、対象は scalar type のオブジェクトで bit-field ではないもの、または非ゼロ長のビットフィールドの最大連続シーケンスのいずれかである。
注記: references や virtual functions など、言語の様々な機能には、プログラムからアクセスできないが実装によって管理される追加のメモリ領域が関与する場合があります。
struct S { char a; // メモリ位置 #1 int b : 5; // メモリ位置 #2 int c : 11, // メモリ位置 #2 (続き) : 0, d : 8; // メモリ位置 #3 struct { int ee : 8; // メモリ位置 #4 } e; } obj; // オブジェクト「obj」は4つの独立したメモリ位置で構成されています
不具合報告
以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。
| DR | 適用対象 | 公開時の動作 | 正しい動作 |
|---|---|---|---|
| CWG 1953 | C++98 |
同じストレージを占有するオブジェクトは
異なるメモリロケーションと見なされていた |
メモリロケーションは
現在はストレージを参照する |
関連項目
|
C documentation
for
Memory model
|