トリッキーなコード
■ このスレッドは過去ログ倉庫に格納されています
0771デフォルトの名無しさん
NGNGISO/IEC 14882:1998 によると、
> [expr.sizeof] 5.3.3 Sizeof
> 1 The sizeof operator yields the number of bytes in the object representation of its operand. The operand
> is either an expression, which is not evaluated, or a parenthesized type-id. The sizeof operator shall not
> be applied to an expression that has function or incomplete type, or to an enumeration type before all its
> enumerators have been declared, or to the parenthesized name of such types, or to an lvalue that designates
> a bit-field. sizeof(char), sizeof(signed char) and sizeof(unsigned char) are 1; the
> result of sizeof applied to any other fundamental type (3.9.1) is implementation-defined. [Note: in par-ticular,
> sizeof(bool) and sizeof(wchar_t) are implementation-defined.69) ] [Note: See 1.7 for
> the definition of byte and 3.9 for the definition of object representation. ]
となっており、
> [intro.memory] 1.7 The C++ memory model
> 1 The fundamental storage unit in the C++ memory model is the byte. A byte is at least large enough to con-tain
> any member of the basic execution character set and is composed of a contiguous sequence of bits, the
> number of which is implementation-defined. The least significant bit is called the low-order bit; the most
> significant bit is called the high-order bit. The memory available to a C++ program consists of one or more
> sequences of contiguous bytes. Every byte has a unique address.
> 2 [Note: the representation of types is described in 3.9. ]
となってます。
つまり、
1バイト=文字集合の要素を保持できるサイズ
charのサイズ=1バイト
というわけ。
知ったかぶりはお前の方だ。
■ このスレッドは過去ログ倉庫に格納されています