Стандарт C++ 98 (1119566), страница 17
Текст из файла (страница 17)
The declared type of an array object might be anarray of incomplete class type and therefore incomplete; if the class type is completed later on in the translation unit, the array type becomes complete; the array type at those two points is the same type. Thedeclared type of an array object might be an array of unknown size and therefore be incomplete at one pointin a translation unit and complete later on; the array types at those two points (“array of unknown bound ofT” and “array of N T”) are different types. The type of a pointer to array of unknown size, or of a typedefined by a typedef declaration to be an array of unknown size, cannot be completed.
[Example:class X;extern X* xp;extern int arr[];typedef int UNKA[];UNKA* arrp;UNKA** arrpp;void foo(){xp++;arrp++;arrpp++;}struct X { int i; };int arr[10];X x;void bar(){xp = &x;arrp = &arr;xp++;arrp++;}// X is an incomplete type// xp is a pointer to an incomplete type// the type of arr is incomplete// UNKA is an incomplete type// arrp is a pointer to an incomplete type// ill-formed: X is incomplete// ill-formed: incomplete type// OK: sizeof UNKA* is known// now X is a complete type// now the type of arr is complete// OK; type is ‘‘pointer to X’’// ill-formed: different types// OK: X is complete// ill-formed: UNKA can’t be completed—end example]8[Note: the rules for declarations and expressions describe in which contexts incomplete types are prohibited.
]9An object type is a (possibly cv-qualified) type that is not a function type, not a reference type, and not avoid type.10Arithmetic types (3.9.1), enumeration types, pointer types, and pointer to member types (3.9.2), and cvqualified versions of these types (3.9.3) are collectively called scalar types. Scalar types, POD-struct types,POD-union types (clause 9), arrays of such types and cv-qualified versions of these types (3.9.3) are collectively called POD types.11If two types T1 and T2 are the same type, then T1 and T2 are layout-compatible types. [Note: Layoutcompatible enumerations are described in 7.2.
Layout-compatible POD-structs and POD-unions aredescribed in 9.2. ]__________________38) The size and layout of an instance of an incompletely-defined object type is unknown.52© ISO/IEC3 Basic concepts3.9.1 Fundamental typesISO/IEC 14882:1998(E)3.9.1 Fundamental types[basic.fundamental]1Objects declared as characters (char) shall be large enough to store any member of the implementation’sbasic character set. If a character from this set is stored in a character object, the integral value of that character object is equal to the value of the single character literal form of that character. It is implementationdefined whether a char object can hold negative values.
Characters can be explicitly declared unsignedor signed. Plain char, signed char, and unsigned char are three distinct types. A char, asigned char, and an unsigned char occupy the same amount of storage and have the same alignment requirements (3.9); that is, they have the same object representation. For character types, all bits ofthe object representation participate in the value representation.
For unsigned character types, all possiblebit patterns of the value representation represent numbers. These requirements do not hold for other types.In any particular implementation, a plain char object can take on either the same values as asigned char or an unsigned char; which one is implementation-defined.2There are four signed integer types: “signed char”, “short int”, “int”, and “long int.” In thislist, each type provides at least as much storage as those preceding it in the list. Plain ints have the natural size suggested by the architecture of the execution environment39) ; the other signed integer types areprovided to meet special needs.3For each of the signed integer types, there exists a corresponding (but different) unsigned integer type:“unsigned char”, “unsigned short int”, “unsigned int”, and “unsigned longint,” each of which occupies the same amount of storage and has the same alignment requirements (3.9)as the corresponding signed integer type40) ; that is, each signed integer type has the same object representation as its corresponding unsigned integer type.
The range of nonnegative values of a signed integer typeis a subrange of the corresponding unsigned integer type, and the value representation of each corresponding signed/unsigned type shall be the same.4Unsigned integers, declared unsigned, shall obey the laws of arithmetic modulo 2 n where n is the number of bits in the value representation of that particular size of integer.41)5Type wchar_t is a distinct type whose values can represent distinct codes for all members of the largestextended character set specified among the supported locales (22.1.1). Type wchar_t shall have the samesize, signedness, and alignment requirements (3.9) as one of the other integral types, called its underlyingtype.6Values of type bool are either true or false.42) [Note: there are no signed, unsigned, short, orlong bool types or values.
] As described below, bool values behave as integral types. Values of typebool participate in integral promotions (4.5).7Types bool, char, wchar_t, and the signed and unsigned integer types are collectively called integraltypes.43) A synonym for integral type is integer type. The representations of integral types shall define values by use of a pure binary numeration system.44) [Example: this International Standard permits 2’s complement, 1’s complement and signed magnitude representations for integral types.
]8There are three floating point types: float, double, and long double. The type double providesat least as much precision as float, and the type long double provides at least as much precision asdouble. The set of values of the type float is a subset of the set of values of the type double; the set__________________39) that is, large enough to contain any value in the range of INT_MIN and INT_MAX, as defined in the header <climits>.40) See 7.1.5.2 regarding the correspondence between types and the sequences of type-specifiers that designate them.41) This implies that unsigned arithmetic does not overflow because a result that cannot be represented by the resulting unsigned integer type is reduced modulo the number that is one greater than the largest value that can be represented by the resulting unsigned integer type.42) Using a bool value in ways described by this International Standard as ‘‘undefined,’’ such as by examining the value of an uninitialized automatic variable, might cause it to behave as if is neither true nor false.43) Therefore, enumerations (7.2) are not integral; however, enumerations can be promoted to int, unsigned int, long, orunsigned long, as specified in 4.5.44) A positional representation for integers that uses the binary digits 0 and 1, in which the values represented by successive bits areadditive, begin with 1, and are multiplied by successive integral power of 2, except perhaps for the bit with the highest position.(Adapted from the American National Dictionary for Information Processing Systems.)53ISO/IEC 14882:1998(E)3.9.1 Fundamental types© ISO/IEC3 Basic conceptsof values of the type double is a subset of the set of values of the type long double.
The value representation of floating-point types is implementation-defined. Integral and floating types are collectivelycalled arithmetic types. Specializations of the standard template numeric_limits (18.2) shall specifythe maximum and minimum values of each arithmetic type for an implementation.9The void type has an empty set of values. The void type is an incomplete type that cannot be completed.It is used as the return type for functions that do not return a value. Any expression can be explicitly converted to type cv void (5.4). An expression of type void shall be used only as an expression statement(6.2), as an operand of a comma expression (5.18), as a second or third operand of ?: (5.16), as the operandof typeid, or as the expression in a return statement (6.6.3) for a function with the return type void.10[Note: even if the implementation defines two or more basic types to have the same value representation,they are nevertheless different types.