Стандарт C++ 98 (1119566), страница 21
Текст из файла (страница 21)
Its type depends on its form (2.13). A string literal is an lvalue; all otherliterals are rvalues.3The keyword this names a pointer to the object for which a nonstatic member function (9.3.2) is invoked.The keyword this shall be used only inside a nonstatic class member function body (9.3) or in a constructor mem-initializer (12.6.2). The type of the expression is a pointer to the function’s class (9.3.2), possiblywith cv-qualifiers on the class type.
The expression is an rvalue.4The operator :: followed by an identifier, a qualified-id, or an operator-function-id is a primaryexpression. Its type is specified by the declaration of the identifier, qualified-id, or operator-function-id.The result is the entity denoted by the identifier, qualified-id, or operator-function-id. The result is anlvalue if the entity is a function or variable. The identifier, qualified-id, or operator-function-id shall have__________________54) As a consequence, operands of type bool, wchar_t, or an enumerated type are converted to some integral type.55) The cast and assignment operators must still perform their specific conversions as described in 5.4, 5.2.9 and 5.17.64© ISO/IEC5 ExpressionsISO/IEC 14882:1998(E)5.1 Primary expressionsglobal namespace scope or be visible in global scope because of a using-directive (7.3.4).
[Note: the use of:: allows a type, an object, a function, an enumerator, or a namespace declared in the global namespace tobe referred to even if its identifier has been hidden (3.4.3). ]5A parenthesized expression is a primary expression whose type and value are identical to those of theenclosed expression. The presence of parentheses does not affect whether the expression is an lvalue.
Theparenthesized expression can be used in exactly the same contexts as those where the enclosed expressioncan be used, and with the same meaning, except as otherwise indicated.6An id-expression is a restricted form of a primary-expression. [Note: an id-expression can appear after .and -> operators (5.2.5). ]7An identifier is an id-expression provided it has been suitably declared (clause 7).
[Note: for operatorfunction-ids, see 13.5; for conversion-function-ids, see 12.3.2; for template-ids, see 14.2. A class-nameprefixed by ~ denotes a destructor; see 12.4. Within the definition of a nonstatic member function, anidentifier that names a nonstatic member is transformed to a class member access expression (9.3.1). ] Thetype of the expression is the type of the identifier. The result is the entity denoted by the identifier.
Theresult is an lvalue if the entity is a function, variable, or data member.qualified-id:::opt nested-name-specifier templateopt unqualified-id:: identifier:: operator-function-id:: template-idnested-name-specifier:class-or-namespace-name :: nested-name-specifieroptclass-or-namespace-name :: template nested-name-specifierclass-or-namespace-name:class-namenamespace-nameA nested-name-specifier that names a class, optionally followed by the keyword template (14.8.1), andthen followed by the name of a member of either that class (9.2) or one of its base classes (clause 10), is aqualified-id; 3.4.3.1 describes name lookup for class members that appear in qualified-ids.
The result is themember. The type of the result is the type of the member. The result is an lvalue if the member is a staticmember function or a data member. [Note: a class member can be referred to using a qualified-id at anypoint in its potential scope (3.3.6). ] Where class-name :: class-name is used, and the two class-namesrefer to the same class, this notation names the constructor (12.1).
Where class-name :: ~ class-name isused, the two class-names shall refer to the same class; this notation names the destructor (12.4). [Note: atypedef-name that names a class is a class-name (7.1.3). Except as the identifier in the declarator for a constructor or destructor definition outside of a class member-specification (12.1, 12.4), a typedef-name thatnames a class may be used in a qualified-id to refer to a constructor or destructor. ]8A nested-name-specifier that names a namespace (7.3), followed by the name of a member of that namespace (or the name of a member of a namespace made visible by a using-directive ) is a qualified-id; 3.4.3.2describes name lookup for namespace members that appear in qualified-ids. The result is the member.
Thetype of the result is the type of the member. The result is an lvalue if the member is a function or a variable.9In a qualified-id, if the id-expression is a conversion-function-id, its conversion-type-id shall denote thesame type in both the context in which the entire qualified-id occurs and in the context of the class denotedby the nested-name-specifier.10An id-expression that denotes a nonstatic data member or nonstatic member function of a class can only beused:— as part of a class member access (5.2.5) in which the object-expression refers to the member’s class or aclass derived from that class, or65ISO/IEC 14882:1998(E)5.1 Primary expressions© ISO/IEC5 Expressions— to form a pointer to member (5.3.1), or— in the body of a nonstatic member function of that class or of a class derived from that class (9.3.1), or— in a mem-initializer for a constructor for that class or for a class derived from that class (12.6.2).11A template-id shall be used as an unqualified-id only as specified in 14.7.2, 14.7, and 14.5.4.5.2 Postfix expressions1[expr.post]Postfix expressions group left-to-right.postfix-expression:primary-expressionpostfix-expression [ expression ]postfix-expression ( expression-listopt )simple-type-specifier ( expression-listopt )typename ::opt nested-name-specifier identifier ( expression-listopt )typename ::opt nested-name-specifier templateopt template-id ( expression-listopt )postfix-expression .
templateopt id-expressionpostfix-expression -> templateopt id-expressionpostfix-expression . pseudo-destructor-namepostfix-expression -> pseudo-destructor-namepostfix-expression ++postfix-expression -dynamic_cast < type-id > ( expression )static_cast < type-id > ( expression )reinterpret_cast < type-id > ( expression )const_cast < type-id > ( expression )typeid ( expression )typeid ( type-id )expression-list:assignment-expressionexpression-list , assignment-expressionpseudo-destructor-name:::opt nested-name-specifieropt type-name :: ~ type-name::opt nested-name-specifier template template-id :: ~ type-name::opt nested-name-specifieropt ~ type-name5.2.1 Subscripting1A postfix expression followed by an expression in square brackets is a postfix expression.
One of theexpressions shall have the type “pointer to T” and the other shall have enumeration or integral type. Theresult is an lvalue of type “T.” The type “T” shall be a completely-defined object type.56) The expressionE1[E2] is identical (by definition) to *((E1)+(E2)). [Note: see 5.3 and 5.7 for details of * and + and8.3.4 for details of arrays. ]5.2.2 Function call1[expr.sub][expr.call]There are two kinds of function call: ordinary function call and member function57) (9.3) call. A functioncall is a postfix expression followed by parentheses containing a possibly empty, comma-separated list ofexpressions which constitute the arguments to the function. For an ordinary function call, the postfixexpression shall be either an lvalue that refers to a function (in which case the function-to-pointer standardconversion (4.3) is suppressed on the postfix expression), or it shall have pointer to function type.
Calling afunction through an expression whose function type has a language linkage that is different from the__________________56) This is true even if the subscript operator is used in the following common idiom: &x[0].57) A static member function (9.4) is an ordinary function.66© ISO/IEC5 ExpressionsISO/IEC 14882:1998(E)5.2.2 Function calllanguage linkage of the function type of the called function’s definition is undefined (7.5). For a memberfunction call, the postfix expression shall be an implicit (9.3.1, 9.4) or explicit class member access (5.2.5)whose id-expression is a function member name, or a pointer-to-member expression (5.5) selecting a function member.