Стандарт C++ 98 (1119566), страница 18
Текст из файла (страница 18)
]3.9.2 Compound types1[basic.compound]Compound types can be constructed in the following ways:— arrays of objects of a given type, 8.3.4;— functions, which have parameters of given types and return void or references or objects of a giventype, 8.3.5;— pointers to void or objects or functions (including static members of classes) of a given type, 8.3.1;— references to objects or functions of a given type, 8.3.2;— classes containing a sequence of objects of various types (clause 9), a set of types, enumerations andfunctions for manipulating these objects (9.3), and a set of restrictions on the access to these entities(clause 11);— unions, which are classes capable of containing objects of different types at different times, 9.5;— enumerations, which comprise a set of named constant values.
Each distinct enumeration constitutes adifferent enumerated type, 7.2;— pointers to non-static45) class members, which identify members of a given type within objects of agiven class, 8.3.3.2These methods of constructing types can be applied recursively; restrictions are mentioned in 8.3.1, 8.3.4,8.3.5, and 8.3.2.3A pointer to objects of type T is referred to as a “pointer to T.” [Example: a pointer to an object of type intis referred to as “pointer to int” and a pointer to an object of class X is called a “pointer to X.” ] Except forpointers to static members, text referring to “pointers” does not apply to pointers to members. Pointers toincomplete types are allowed although there are restrictions on what can be done with them (3.9).
Thevalue representation of pointer types is implementation-defined. Pointers to cv-qualified and cvunqualified versions (3.9.3) of layout-compatible types shall have the same value representation and alignment requirements (3.9).4Objects of cv-qualified (3.9.3) or cv-unqualified type void* (pointer to void), can be used to point toobjects of unknown type. A void* shall be able to hold any object pointer. A cv-qualified or cvunqualified (3.9.3) void* shall have the same representation and alignment requirements as a cv-qualifiedor cv-unqualified char*.__________________45) Static class members are objects or functions, and pointers to them are ordinary pointers to objects or functions.54© ISO/IECISO/IEC 14882:1998(E)3 Basic concepts3.9.3 CV-qualifiers3.9.3 CV-qualifiers[basic.type.qualifier]1A type mentioned in 3.9.1 and 3.9.2 is a cv-unqualified type. Each type which is a cv-unqualified completeor incomplete object type or is void (3.9) has three corresponding cv-qualified versions of its type: aconst-qualified version, a volatile-qualified version, and a const-volatile-qualified version.
The term objecttype (1.8) includes the cv-qualifiers specified when the object is created. The presence of a const specifier in a decl-specifier-seq declares an object of const-qualified object type; such object is called a constobject. The presence of a volatile specifier in a decl-specifier-seq declares an object of volatilequalified object type; such object is called a volatile object. The presence of both cv-qualifiers in a declspecifier-seq declares an object of const-volatile-qualified object type; such object is called a const volatileobject.
The cv-qualified or cv-unqualified versions of a type are distinct types; however, they shall havethe same representation and alignment requirements (3.9).46)2A compound type (3.9.2) is not cv-qualified by the cv-qualifiers (if any) of the types from which it is compounded. Any cv-qualifiers applied to an array type affect the array element type, not the array type (8.3.4).3Each non-static, non-mutable, non-reference data member of a const-qualified class object is constqualified, each non-static, non-reference data member of a volatile-qualified class object is volatilequalified and similarly for members of a const-volatile class.
See 8.3.5 and 9.3.2 regarding cv-qualifiedfunction types.4There is a (partial) ordering on cv-qualifiers, so that a type can be said to be more cv-qualified than another.Table 6 shows the relations that constitute this ordering.Table 6—relations on const and volatile______________________________________ no cv-qualifier<const no cv-qualifier<volatile<const volatile no cv-qualifierconst<const volatile volatile<const volatile ______________________________________5In this International Standard, the notation cv (or cv1, cv2, etc.), used in the description of types, representsan arbitrary set of cv-qualifiers, i.e., one of {const}, {volatile}, {const, volatile}, or theempty set. Cv-qualifiers applied to an array type attach to the underlying element type, so the notation“cv T,” where T is an array type, refers to an array whose elements are so-qualified.
Such array types canbe said to be more (or less) cv-qualified than other types based on the cv-qualification of the underlying element types.3.10 Lvalues and rvalues[basic.lval]1Every expression is either an lvalue or an rvalue.2An lvalue refers to an object or function. Some rvalue expressions—those of class or cv-qualified classtype—also refer to objects.47)3[Note: some built-in operators and function calls yield lvalues.
[Example: if E is an expression of pointertype, then *E is an lvalue expression referring to the object or function to which E points. As anotherexample, the functionint& f();yields an lvalue, so the call f() is an lvalue expression. ] ]__________________46) The same representation and alignment requirements are meant to imply interchangeability as arguments to functions, return valuesfrom functions, and members of unions.47) Expressions such as invocations of constructors and of functions that return a class type refer to objects, and the implementationcan invoke a member function upon such objects, but the expressions are not lvalues.55ISO/IEC 14882:1998(E)3.10 Lvalues and rvalues© ISO/IEC3 Basic concepts4[Note: some built-in operators expect lvalue operands. [Example: built-in assignment operators all expecttheir left hand operands to be lvalues.
] Other built-in operators yield rvalues, and some expect them.[Example: the unary and binary + operators expect rvalue arguments and yield rvalue results. ] The discussion of each built-in operator in clause 5 indicates whether it expects lvalue operands and whether it yieldsan lvalue. ]5The result of calling a function that does not return a reference is an rvalue. User defined operators arefunctions, and whether such operators expect or yield lvalues is determined by their parameter and returntypes.6An expression which holds a temporary object resulting from a cast to a nonreference type is an rvalue (thisincludes the explicit creation of an object using functional notation (5.2.3)).7Whenever an lvalue appears in a context where an rvalue is expected, the lvalue is converted to an rvalue;see 4.1, 4.2, and 4.3.8The discussion of reference initialization in 8.5.3 and of temporaries in 12.2 indicates the behavior of lvalues and rvalues in other significant contexts.9Class rvalues can have cv-qualified types; non-class rvalues always have cv-unqualified types.
Rvaluesshall always have complete types or the void type; in addition to these types, lvalues can also have incomplete types.10An lvalue for an object is necessary in order to modify the object except that an rvalue of class type canalso be used to modify its referent under certain circumstances. [Example: a member function called for anobject (9.3) can modify the object. ]11Functions cannot be modified, but pointers to functions can be modifiable.12A pointer to an incomplete type can be modifiable. At some point in the program when the pointed to typeis complete, the object at which the pointer points can also be modified.13The referent of a const-qualified expression shall not be modified (through that expression), except that ifit is of class type and has a mutable component, that component can be modified (7.1.5.1).14If an expression can be used to modify the object to which it refers, the expression is called modifiable.
Aprogram that attempts to modify an object through a nonmodifiable lvalue or rvalue expression is illformed.15If a program attempts to access the stored value of an object through an lvalue of other than one of the following types the behavior is undefined48):— the dynamic type of the object,— a cv-qualified version of the dynamic type of the object,— a type that is the signed or unsigned type corresponding to the dynamic type of the object,— a type that is the signed or unsigned type corresponding to a cv-qualified version of the dynamic type ofthe object,— an aggregate or union type that includes one of the aforementioned types among its members (including, recursively, a member of a subaggregate or contained union),— a type that is a (possibly cv-qualified) base class type of the dynamic type of the object,— a char or unsigned char type.__________________48) The intent of this list is to specify those circumstances in which an object may or may not be aliased.56© ISO/IECISO/IEC 14882:1998(E)4 Standard conversions1[conv]Standard conversions are implicit conversions defined for built-in types.
Clause 4 enumerates the full set ofsuch conversions. A standard conversion sequence is a sequence of standard conversions in the followingorder:— Zero or one conversion from the following set: lvalue-to-rvalue conversion, array-to-pointer conversion,and function-to-pointer conversion.— Zero or one conversion from the following set: integral promotions, floating point promotion, integralconversions, floating point conversions, floating-integral conversions, pointer conversions, pointer tomember conversions, and boolean conversions.— Zero or one qualification conversion.[Note: a standard conversion sequence can be empty, i.e., it can consist of no conversions.