Стандарт C++ 98 (1119566), страница 65
Текст из файла (страница 65)
int and long but excluding e.g. char). Similarly, the termpromoted arithmetic type refers to promoted integral types plus floating types. [Note: in all cases where apromoted integral type or promoted arithmetic type is required, an operand of enumeration type will beacceptable by way of the integral promotions.
]3For every pair (T, VQ), where T is an arithmetic type, and VQ is either volatile or empty, there existcandidate operator functions of the formVQ T&T4For every pair (T, VQ), where T is an arithmetic type other than bool, and VQ is either volatile orempty, there exist candidate operator functions of the formVQ T&T5operator*(T*);For every type T, there exist candidate operator functions of the formT*9operator*(T*);For every function type T, there exist candidate operator functions of the formT&8operator++(T*VQ&);operator--(T*VQ&);operator++(T*VQ&, int);operator--(T*VQ&, int);For every cv-qualified or cv-unqualified object type T, there exist candidate operator functions of the formT&7operator--(VQ T&);operator--(VQ T&, int);For every pair (T, VQ), where T is a cv-qualified or cv-unqualified object type, and VQ is either volatileor empty, there exist candidate operator functions of the formT*VQ&T*VQ&T*T*6operator++(VQ T&);operator++(VQ T&, int);operator+(T*);For every promoted arithmetic type T, there exist candidate operator functions of the formTToperator+(T);operator-(T);231ISO/IEC 14882:1998(E)© ISO/IEC13.6 Built-in operators10For every promoted integral type T, there exist candidate operator functions of the formT1113 Overloadingoperator~(T);For every quintuple (C1, C2, T, CV1, CV2), where C2 is a class type, C1 is the same type as C2 or is aderived class of C2, T is an object type or a function type, and CV1 and CV2 are cv-qualifier-seqs, thereexist candidate operator functions of the formCV12 T&operator->*(CV1 C1*, CV2 T C2::*);where CV12 is the union of CV1 and CV2.12For every pair of promoted arithmetic types L and R, there exist candidate operator functions of the formLRLRLRLRboolboolboolboolboolbooloperator*(L, R);operator/(L, R);operator+(L, R);operator-(L, R);operator<(L, R);operator>(L, R);operator<=(L, R);operator>=(L, R);operator==(L, R);operator!=(L, R);where LR is the result of the usual arithmetic conversions between types L and R.13For every cv-qualified or cv-unqualified object type T there exist candidate operator functions of the formT*T&T*T*T&14operator+(T*, ptrdiff_t);operator[](T*, ptrdiff_t);operator-(T*, ptrdiff_t);operator+(ptrdiff_t, T*);operator[](ptrdiff_t, T*);For every T, where T is a pointer to object type, there exist candidate operator functions of the formptrdiff_t15For every pointer or enumeration type T, there exist candidate operator functions of the formboolboolboolboolboolbool16operator<(T, T);operator>(T, T);operator<=(T, T);operator>=(T, T);operator==(T, T);operator!=(T, T);For every pointer to member type T, there exist candidate operator functions of the formboolbool17operator-(T, T);operator==(T, T);operator!=(T, T);For every pair of promoted integral types L and R, there exist candidate operator functions of the formLRLRLRLRLLoperator%(L, R);operator&(L, R);operator^(L, R);operator|(L, R);operator<<(L, R);operator>>(L, R);where LR is the result of the usual arithmetic conversions between types L and R.232© ISO/IECISO/IEC 14882:1998(E)13 Overloading18For every triple (L, VQ, R), where L is an arithmetic type, VQ is either volatile or empty, and R is apromoted arithmetic type, there exist candidate operator functions of the formVQ L&VQ L&VQ L&VQ L&VQ L&19operator%=(VQ L&, R);operator<<=(VQ L&, R);operator>>=(VQ L&, R);operator&=(VQ L&, R);operator^=(VQ L&, R);operator|=(VQ L&, R);There also exist candidate operator functions of the formboolboolbool24operator+=(T*VQ&, ptrdiff_t);operator-=(T*VQ&, ptrdiff_t);For every triple (L, VQ, R), where L is an integral type, VQ is either volatile or empty, and R is a promoted integral type, there exist candidate operator functions of the formVQ L&VQ L&VQ L&VQ L&VQ L&VQ L&23operator=(VQ T&, T);For every pair (T, VQ), where T is a cv-qualified or cv-unqualified object type and VQ is either volatileor empty, there exist candidate operator functions of the formT*VQ&T*VQ&22operator=(T*VQ&, T*);For every pair (T, VQ), where T is an enumeration or pointer to member type and VQ is either volatileor empty, there exist candidate operator functions of the formVQ T&21operator=(VQ L&, R);operator*=(VQ L&, R);operator/=(VQ L&, R);operator+=(VQ L&, R);operator-=(VQ L&, R);For every pair (T, VQ), where T is any type and VQ is either volatile or empty, there exist candidateoperator functions of the formT*VQ&2013.6 Built-in operatorsoperator!(bool);operator&&(bool, bool);operator||(bool, bool);For every pair of promoted arithmetic types L and R, there exist candidate operator functions of the formLRoperator?(bool, L, R);where LR is the result of the usual arithmetic conversions between types L and R.
[Note: as with all thesedescriptions of candidate functions, this declaration serves only to describe the built-in operator for purposes of overload resolution. The operator “?” cannot be overloaded. ]25For every type T, where T is a pointer or pointer-to-member type, there exist candidate operator functionsof the formToperator?(bool, T, T);233ISO/IEC 14882:1998(E)©(Blank page)234ISO/IEC© ISO/IEC14 Templates14 Templates1ISO/IEC 14882:1998(E)14 Templates[temp]A template defines a family of classes or functions.template-declaration:exportopt template < template-parameter-list > declarationtemplate-parameter-list:template-parametertemplate-parameter-list , template-parameterThe declaration in a template-declaration shall— declare or define a function or a class, or— define a member function, a member class or a static data member of a class template or of a classnested within a class template, or— define a member template of a class or class template.A template-declaration is a declaration.
A template-declaration is also a definition if its declarationdefines a function, a class, or a static data member.2A template-declaration can appear only as a namespace scope or class scope declaration. In a functiontemplate declaration, the declarator-id shall be a template-name (i.e., not a template-id). [Note: in a classtemplate declaration, if the declarator-id is a template-id, the declaration declares a class template partialspecialization (14.5.4). ]3In a template-declaration, explicit specialization, or explicit instantiation the init-declarator-list in the declaration shall contain at most one declarator. When such a declaration is used to declare a class template,no declarator is permitted.4A template name may have linkage (3.5). A template, a template explicit specialization (14.7.3), or a classtemplate partial specialization shall not have C linkage. If the linkage of one of these is something otherthan C or C++, the behavior is implementation-defined.
Template definitions shall obey the one definitionrule (3.2). [Note: default arguments for function templates and for member functions of class templates areconsidered definitions for the purpose of template instantiation (14.5) and must also obey the one definitionrule. ]5A class template shall not have the same name as any other template, class, function, object, enumeration,enumerator, namespace, or type in the same scope (3.3), except as specified in (14.5.4). Except that a function template can be overloaded either by (non-template) functions with the same name or by other functiontemplates with the same name (14.8.3), a template name declared in namespace scope or in class scopeshall be unique in that scope.6A namespace-scope declaration or definition of a non-inline function template, a non-inline member function template, a non-inline member function of a class template or a static data member of a class templatemay be preceded by the export keyword.
If such a template is defined in the same translation unit inwhich it is declared as exported, the definition is considered to be exported. The first declaration of thetemplate containing the export keyword must not follow the definition.7Declaring a class template exported is equivalent to declaring all of its non-inline function members, staticdata members, member classes, member class templates and non-inline function member templates whichare defined in that translation unit exported.8Templates defined in an unnamed namespace shall not be exported. A template shall be exported only oncein a program. An implementation is not required to diagnose a violation of this rule. A non-exported template that is neither explicitly specialized nor explicitly instantiated must be defined in every translation235ISO/IEC 14882:1998(E)14 Templates© ISO/IEC14 Templatesunit in which it is implicitly instantiated (14.7.1) or explicitly instantiated (14.7.2); no diagnostic isrequired.