Стандарт C++ 98 (1119566), страница 85
Текст из файла (страница 85)
For example, if a clause does not specify any requirements, therewill be no ‘‘Requirements’’ subclause.313ISO/IEC 14882:1998(E)© ISO/IEC17.3.1 Structure of each subclause17 Library introduction— References to the Standard C library17.3.1.1 Summary[lib.structure.summary]1The Summary provides a synopsis of the category, and introduces the first-level subclauses. Each subclause also provides a summary, listing the headers specified in the subclause and the library entities provided in each header.2Paragraphs labelled ‘‘Note(s):’’ or ‘‘Example(s):’’ are informative, other paragraphs are normative.3The summary and the detailed specifications are presented in the order:— Macros— Values— Types— Classes— Functions— Objects17.3.1.2 Requirements1[lib.structure.requirements]The library can be extended by a C++ program.
Each clause, as applicable, describes the requirements thatsuch extensions must meet. Such extensions are generally one of the following:— Template arguments— Derived classes— Containers, iterators, and/or algorithms that meet an interface convention2The string and iostreams components use an explicit representation of operations required of template arguments. They use a template class name char_traits to define these constraints.3Interface convention requirements are stated as generally as possible.
Instead of stating ‘‘class X has todefine a member function operator++(),’’ the interface requires ‘‘for any object x of class X, ++x isdefined.’’ That is, whether the operator is a member is unspecified.4Requirements are stated in terms of well-defined expressions, which define valid terms of the types that satisfy the requirements. For every set of requirements there is a table that specifies an initial set of the validexpressions and their semantics (20.1.5, 23.1, 24.1).
Any generic algorithm (clause 25) that uses therequirements is described in terms of the valid expressions for its formal type parameters.5Template argument requirements are sometimes referenced by name. See 17.3.2.1.6In some cases the semantic requirements are presented as C++ code. Such code is intended as a specification of equivalence of a construct to another construct, not necessarily as the way the construct must beimplemented.145)17.3.1.3 Specifications1The detailed specifications each contain the following elements:[lib.structure.specifications]146)— Name and brief description— Synopsis (class definition or function prototype, as appropriate)— Restrictions on template arguments, if any__________________145) Although in some cases the code given is unambiguously the optimum implementation.146) The form of these specifications was designed to follow the conventions established by existing C++ library vendors.314© ISO/IEC17 Library introductionISO/IEC 14882:1998(E)17.3.1.3 Specifications— Description of class invariants— Description of function semantics2Descriptions of class member functions follow the order (as appropriate):147)— Constructor(s) and destructor— Copying & assignment functions— Comparison functions— Modifier functions— Observer functions— Operators and other non-member functions3Descriptions of function semantics contain the following elements (as appropriate):148)— Requires: the preconditions for calling the function— Effects: the actions performed by the function— Postconditions: the observable results established by the function— Returns: a description of the value(s) returned by the function— Throws: any exceptions thrown by the function, and the conditions that would cause the exception— Complexity: the time and/or space complexity of the function4For non-reserved replacement and handler functions, Clause 18 specifies two behaviors for the functions inquestion: their required and default behavior.
The default behavior describes a function definition providedby the implementation. The required behavior describes the semantics of a function definition provided byeither the implementation or a C++ program. Where no distinction is explicitly made in the description, thebehavior described is the required behavior.5Complexity requirements specified in the library clauses are upper bounds, and implementations that provide better complexity guarantees satisfy the requirements.17.3.1.4 C Library1Paragraphs labelled ‘‘SEE ALSO:’’ contain cross-references to the relevant portions of this Standard and theISO C standard, which is incorporated into this Standard by reference.17.3.2 Other conventions1[lib.conventions]This subclause describes several editorial conventions used to describe the contents of the C++ StandardLibrary.
These conventions are for describing implementation-defined types (17.3.2.1), and member functions (17.3.2.2).17.3.2.1 Type descriptions1[lib.structure.see.also][lib.type.descriptions]The Requirements subclauses may describe names that are used to specify constraints on template arguments.149) These names are used in clauses 20, 23, 25, and 26 to describe the types that may be supplied asarguments by a C++ program when instantiating template components from the library.__________________147) To save space, items that do not apply to a class are omitted. For example, if a class does not specify any comparison functions,there will be no ‘‘Comparison functions’’ subclause.148) To save space, items that do not apply to a function are omitted.
For example, if a function does not specify any preconditions,there will be no ‘‘Requires’’ paragraph.149) Examples from 20.1 include: EqualityComparable, LessThanComparable, CopyConstructable, etc. Examplesfrom 24.1 include: InputIterator, ForwardIterator, Function, Predicate, etc.3152ISO/IEC 14882:1998(E)© ISO/IEC17.3.2.1 Type descriptions17 Library introductionCertain types defined in clause 27 are used to describe implementation-defined types.
They are based onother types, but with added constraints.17.3.2.1.1 Enumerated types[lib.enumerated.types]1Several types defined in clause 27 are enumerated types. Each enumerated type may be implemented as anenumeration or as a synonym for an enumeration.150)2The enumerated type enumerated can be written:enum enumerated { V0, V1, V2, V3, .....};static conststatic conststatic conststatic const.....3enumeratedenumeratedenumeratedenumeratedC0(V0);C1(V1);C2(V2);C3(V3);Here, the names C0, C1, etc. represent enumerated elements for this particular enumerated type.
All suchelements have distinct values.17.3.2.1.2 Bitmask types[lib.bitmask.types]1Several types defined in clause 27 are bitmask types. Each bitmask type can be implemented as an enumerated type that overloads certain operators, as an integer type, or as a bitset (23.3.5).2The bitmask type bitmask can be written:enum bitmask {V0 = 1 << 0, V1 = 1 << 1, V2 = 1 << 2, V3 = 1 << 3, .....};static conststatic conststatic conststatic const.....bitmaskbitmaskbitmaskbitmaskbitmaskC0(V0);C1(V1);C2(V2);C3(V3);operator& (bitmask X, bitmask Y)// For exposition only.// int_type is an integral type capable of// representing all values of bitmask{ return static_cast<bitmask>(static_cast<int_type>(X) &static_cast<int_type>(Y)); }bitmaskoperator| (bitmask X, bitmask Y){ return static_cast<bitmask>(static_cast<int_type>(X) |static_cast<int_type>(Y)); }bitmask operator^ (bitmask X, bitmask Y){ return static_cast<bitmask>(static_cast<int_type>(X) ^static_cast<int_type>(Y)); }bitmask operator~ (bitmask X){ return static_cast<bitmask>(static_cast<int_type>(~X)); }__________________150) Such as an integer type, with constant integer values (3.9.1).316© ISO/IECISO/IEC 14882:1998(E)17 Library introduction17.3.2.1.2 Bitmask typesbitmask& operator&=(bitmask& X, bitmask Y){ X = X & Y; return X; }bitmask& operator|=(bitmask& X, bitmask Y){ X = X | Y; return X; }bitmask& operator^=(bitmask& X, bitmask Y){ X = X ^ Y; return X; }3Here, the names C0, C1, etc.
represent bitmask elements for this particular bitmask type. All such elements have distinct values such that, for any pair Ci and Cj, Ci & Ci is nonzero and Ci & Cj is zero.4The following terms apply to objects and values of bitmask types:— To set a value Y in an object X is to evaluate the expression X = Y.— To clear a value Y in an object X is to evaluate the expression X &= ˜Y.— The value Y is set in the object X if the expression X & Y is nonzero.17.3.2.1.3 Character sequences1[lib.character.seq]The Standard C library makes widespread use of characters and character sequences that follow a few uniform conventions:— A letter is any of the 26 lowercase or 26 uppercase letters in the basic execution character set.151)— The decimal-point character is the (single-byte) character used by functions that convert between a(single-byte) character sequence and a value of one of the floating-point types.
It is used in the character sequence to denote the beginning of a fractional part. It is represented in clauses 18 through 27 by aperiod, ’.’, which is also its value in the "C" locale, but may change during program execution by acall to setlocale(int, const char*),152) or by a change to a locale object, as described inclauses 22.1 and 27.— A character sequence is an array object (8.3.4) A that can be declared as T A[N], where T is any of thetypes char, unsigned char, or signed char (3.9.1), optionally qualified by any combinationof const or volatile. The initial elements of the array have defined contents up to and includingan element determined by some predicate. A character sequence can be designated by a pointer value Sthat points to its first element.17.3.2.1.3.1 Byte strings[lib.byte.strings]1A null-terminated byte string, or NTBS, is a character sequence whose highest-addressed element withdefined content has the value zero (the terminating null character).153)2The length of an NTBS is the number of elements that precede the terminating null character.
An empty NTBShas a length of zero.3The value of ancharacter.4A static NTBS is an NTBS with static storage duration.154)NTBSis the sequence of values of the elements up to and including the terminating null__________________151) Note that this definition differs from the definition in ISO C subclause 7.1.1.152) declared in <clocale> (22.3).153) Many of the objects manipulated by function signatures declared in <cstring> (21.4) are character sequences orsize of some of these character sequences is limited by a length value, maintained separately from the character sequence.154) A string literal, such as "abc", is a static NTBS.NTBSs.The317ISO/IEC 14882:1998(E)© ISO/IEC17.3.2.1.3.2 Multibyte strings17 Library introduction17.3.2.1.3.2 Multibyte strings[lib.multibyte.strings]1A null-terminated multibyte string, or NTMBS, is an NTBS that constitutes a sequence of valid multibyte characters, beginning and ending in the initial shift state.155)2A static NTMBS is an NTMBS with static storage duration.17.3.2.1.3.3 Wide-character sequences[lib.wide.characters]1A wide-character sequence is an array object (8.3.4) A that can be declared as T A[N], where T is typewchar_t (3.9.1), optionally qualified by any combination of const or volatile.