17 Library introduction [lib.library]

1 This clause describes the contents of the C++ Standard Library, how a well-formed C++ program makes use of the library, and how a conforming implementation may provide the entities in the library.

2 The C++ Standard Library provides an extensible framework, and contains components for: language support, diagnostics, general utilities, strings, locales, containers, iterators, algorithms, numerics, and input/output. The language support components are required by certain parts of the C++ language, such as memory allocation (5.3.4, 5.3.5) and exception processing (clause 15).

3 The general utilities include components used by other library elements, such as a predefined storage allocator for dynamic storage management (3.7.3). The diagnostics components provide a consistent framework for reporting errors in a C++ program, including predefined exception classes.

4 The strings components provide support for manipulating text represented as sequences of type char, sequences of type wchar_t, or sequences of any other ``character-like'' type. The localization components extend internationalization support for such text processing.

5 The containers, iterators, and algorithms provide a C++ program with access to a subset of the most widely used algorithms and data structures.

6 Numeric algorithms and the complex number components extend support for numeric processing. The valarray components provide support for n-at-a-time processing, potentially implemented as parallel operations on platforms that support such processing.

7 The iostreams components are the primary mechanism for C++ program input/output. They can be used with other elements of the library, particularly strings, locales, and iterators.

8 This library also makes available the facilities of the Standard C library, suitably adjusted to ensure static type safety.

9 The following subclauses describe the definitions (17.1), and method of description (17.3) for the library. Clause 17.4 and clauses 18 through 27 specify the contents of the library, and library requirements and constraints on both well-formed C++ programs and conforming implementations.

17.1 Definitions [lib.definitions]

17.1.1 arbitrary-positional stream [defns.arbitrary.stream]

a stream (described in clause 27) that can seek to any integral position within the length of the stream. Every arbitrary-positional stream is also a repositional stream (17.1.16).

17.1.2 character [defns.character]

in clauses 21, 22, and 27, means any object which, when treated sequentially, can represent text. The term does not only mean char and wchar_t objects, but any value that can be represented by a type that provides the definitions specified in these clauses.

17.1.3 character container type [defns.character.container]

a class or a type used to represent a character (17.1.2). It is used for one of the template parameters of the string and iostream class templates. A character container class shall be a POD (3.9) type.

17.1.4 comparison function [defns.comparison]

an operator function (13.5) for any of the equality (5.10) or relational (5.9) operators.

17.1.5 component [defns.component]

a group of library entities directly related as members, parameters, or return types. For example, the class template basic_string and the non-member template functions that operate on strings are referred to as the string component.

17.1.6 default behavior [defns.default.behavior]

a description of replacement function and handler function semantics. Any specific behavior provided by the implementation, within the scope of the required behavior.

17.1.7 handler function [defns.handler]

a non-reserved function whose definition may be provided by a C++ program. A C++ program may designate a handler function at various points in its execution, by supplying a pointer to the function when calling any of the library functions that install handler functions (clause 18).

17.1.8 iostream class templates [defns.iostream.templates]

templates, defined in clause 27, that take two template arguments: charT and traits. The argument charT is a character container class, and the argument traits is a structure which defines additional characteristics and functions of the character type represented by charT necessary to implement the iostream class templates.

17.1.9 modifier function [defns.modifier]

a class member function (9.3), other than constructors, assignment, or destructor, that alters the state of an object of the class.

17.1.10 object state [defns.obj.state]

the current value of all nonstatic class members of an object (9.2). The state of an object can be obtained by using one or more observer functions. 17.1.11 narrow-oriented iostream classes the instantiations of the iostream class templates on the character container class char and the default value of the traits parameter. The traditional iostream classes are regarded as the narrow-oriented iostream classes (27.3.1).

17.1.12 NTCTS [defns.ntcts]

a sequence of values that have character type, that precede the terminating null character type value charT().

17.1.13 observer function [defns.observer]

a class member function (9.3) that accesses the state of an object of the class, but does not alter that state. Observer functions are specified as const member functions (9.3.2).

17.1.14 replacement function [defns.replacement]

a non-reserved function whose definition is provided by a C++ program. Only one definition for such a function is in effect for the duration of the program's execution, as the result of creating the program (2.1) and resolving the definitions of all translation units (3.5).

17.1.15 required behavior [defns.required.behavior]

a description of replacement function and handler function semantics, applicable to both the behavior provided by the implementation and the behavior that shall be provided by any function definition in the program. If a function defined in a C++ program fails to meet the required behavior when it executes, the behavior is undefined.

17.1.16 repositional stream [defns.repositional.stream]

a stream (described in clause 27) that can seek only to a position that was previously encountered.

17.1.17 reserved function [defns.reserved.function]

a function, specified as part of the C++ Standard Library, that must be defined by the implementation. If a C++ program provides a definition for any reserved function, the results are undefined.

17.1.18 traits class [defns.traits]

a class that encapsulates a set of types and functions necessary for template classes and template functions to manipulate objects of types for which they are instantiated. Traits classes defined in clauses 21, 22 and 27 are chararacter traits, which provide the character handling support needed by the string and iostream classes. 17.1.19 wide-oriented iostream classes the instantiations of the iostream class templates on the character container class wchar_t and the default value of the traits parameter (27.3.2).

17.2 Additional definitions [defns.additional]

1 1.3 defines additional terms used elsewhere in this International Standard.

17.3 Method of description (Informative) [lib.description]

1 17.3 describes the conventions used to describe the C++ Standard Library. It describes the structures of the normative clauses 18 through 27 (17.3.1), and other editorial conventions (17.3.2).

17.3.1 Structure of each subclause [lib.structure]

1 17.4.1 provides a summary of the C++ Standard library's contents. Other Library clauses provide detailed specifications for each of the components in the library, as shown in Table 10:

Table 10---Library Categories
_ _________________________
_ Clause        Category
_ _________________________
_________________________
  1. Language support
  2. Diagnostics
  3. General utilities
  4. Strings
  5. Localization
  6. Containers
  7. Iterators
  8. Algorithms
  9. Numerics
_ 27 Input/output _________________________

2 Each Library clause contains the following elements, as applicable:144)

144) To save space, items that do not apply to a clause are omitted. For example, if a clause does not specify any requirements, there will be no ``Requirements'' subclause. [back to text]

17.3.1.1 Summary [lib.structure.summary]

1 The 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.

2 Paragraphs labelled ``Note(s):'' or ``Example(s):'' are informative, other paragraphs are normative.

3 The summary and the detailed specifications are presented in the order:

17.3.1.2 Requirements [lib.structure.requirements]

1 The library can be extended by a C++ program. Each clause, as applicable, describes the requirements that such extensions must meet. Such extensions are generally one of the following:

2 The 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.

3 Interface convention requirements are stated as generally as possible. Instead of stating ``class X has to define a member function operator++(),'' the interface requires ``for any object x of class X, ++x is defined.'' That is, whether the operator is a member is unspecified.

4 Requirements 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 valid expressions and their semantics (20.1.5, 23.1, 24.1). Any generic algorithm (clause 25) that uses the requirements is described in terms of the valid expressions for its formal type parameters.

5 Template argument requirements are sometimes referenced by name. See 17.3.2.1.

6 In 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 be implemented.145)

145) Although in some cases the code given is unambiguously the optimum implementation. [back to text]

17.3.1.3 Specifications [lib.structure.specifications]

1 The detailed specifications each contain the following elements:146)

2 Descriptions of class member functions follow the order (as appropriate):147)

3 Descriptions of function semantics contain the following elements (as appropriate):148)

4 For non-reserved replacement and handler functions, Clause 18 specifies two behaviors for the functions in question: their required and default behavior. The default behavior describes a function definition provided by the implementation. The required behavior describes the semantics of a function definition provided by either the implementation or a C++ program. Where no distinction is explicitly made in the description, the behavior described is the required behavior.

5 Complexity requirements specified in the library clauses are upper bounds, and implementations that provide better complexity guarantees satisfy the requirements.

146) The form of these specifications was designed to follow the conventions established by existing C++ library vendors. [back to text]

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. [back to text]

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. [back to text]

17.3.1.4 C Library [lib.structure.see.also]

1 Paragraphs labelled ``SEE ALSO:'' contain cross-references to the relevant portions of this Standard and the ISO C standard, which is incorporated into this Standard by reference.

17.3.2 Other conventions [lib.conventions]

1 This subclause describes several editorial conventions used to describe the contents of the C++ Standard Library. These conventions are for describing implementation-defined types (17.3.2.1), and member functions (17.3.2.2).

17.3.2.1 Type descriptions [lib.type.descriptions]

1 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 as arguments by a C++ program when instantiating template components from the library.

2 Certain types defined in clause 27 are used to describe implementation-defined types. They are based on other types, but with added constraints.

149) Examples from 20.1 include: EqualityComparable, LessThanComparable, CopyConstructable, etc. Examples from 24.1 include: InputIterator, ForwardIterator, Function, Predicate, etc. [back to text]
17.3.2.1.1 Enumerated types [lib.enumerated.types]

1 Several types defined in clause 27 are enumerated types. Each enumerated type may be implemented as an enumeration or as a synonym for an enumeration.150)

2 The enumerated type enumerated can be written:

enum enumerated   { V0,  V1,  V2, V3, .....};

static const   enumerated C0(V0);
static const   enumerated C1(V1);
static const   enumerated C2(V2);
static const   enumerated C3(V3);
  .....

3 Here, the names C0, C1, etc. represent enumerated elements for this particular enumerated type. All such elements have distinct values.

150) Such as an integer type, with constant integer values (3.9.1). [back to text]
17.3.2.1.2 Bitmask types [lib.bitmask.types]

1 Several 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).

2 The bitmask type bitmask can be written:

enum bitmask   {
  V0 = 1 << 0,   V1 = 1 << 1,   V2  = 1 << 2,  V3  = 1 << 3, .....
};

static const   bitmask C0(V0);
static const   bitmask C1(V1);
static const   bitmask C2(V2);
static const   bitmask C3(V3);
  .....

bitmask   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)); }

bitmask   operator| (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)); }
 bitmask& 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; }

3 Here, 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.

4 The following terms apply to objects and values of bitmask types:

17.3.2.1.3 Character sequences [lib.character.seq]

1 The Standard C library makes widespread use of characters and character sequences that follow a few uniform conventions:

151) Note that this definition differs from the definition in ISO C subclause 7.1.1. [back to text]

152) declared in <clocale> (22.3). [back to text]

17.3.2.1.3.1 Byte strings [lib.byte.strings]

1 A null-terminated byte string, or NTBS, is a character sequence whose highest-addressed element with defined content has the value zero (the terminating null character).153)

2 The length of an NTBS is the number of elements that precede the terminating null character. An empty NTBS has a length of zero.

3 The value of an NTBS is the sequence of values of the elements up to and including the terminating null character.

4 A static NTBS is an NTBS with static storage duration.154)

153) Many of the objects manipulated by function signatures declared in <cstring> (21.4) are character sequences or NTBSs. The size of some of these character sequences is limited by a length value, maintained separately from the character sequence. [back to text]

154) A string literal, such as "abc", is a static NTBS. [back to text]

17.3.2.1.3.2 Multibyte strings [lib.multibyte.strings]

1 A 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)

2 A static NTMBS is an NTMBS with static storage duration.

155) An NTBS that contains characters only from the basic execution character set is also an NTMBS. Each multibyte character then consists of a single byte. [back to text]
17.3.2.1.3.3 Wide-character sequences [lib.wide.characters]

1 A wide-character sequence is an array object (8.3.4) A that can be declared as T A[N], where T is type wchar_t (3.9.1), optionally qualified by any combination of const or volatile. The initial elements of the array have defined contents up to and including an element determined by some predicate. A character sequence can be designated by a pointer value S that designates its first element.

2 A null-terminated wide-character string, or NTWCS, is a wide-character sequence whose highest-addressed element with defined content has the value zero.156)

3 The length of an NTWCS is the number of elements that precede the terminating null wide character. An empty NTWCS has a length of zero.

4 The value of an NTWCS is the sequence of values of the elements up to and including the terminating null character.

5 A static NTWCS is an NTWCS with static storage duration.157)

156) Many of the objects manipulated by function signatures declared in <cwchar> are wide-character sequences or NTWCSs. [back to text]

157) A wide string literal, such as L"abc", is a static NTWCS. [back to text]

17.3.2.2 Functions within classes [lib.functions.within.classes]

1 For the sake of exposition, clauses 18 through 27 do not describe copy constructors, assignment operators, or (non-virtual) destructors with the same apparent semantics as those that can be generated by default (12.1, 12.4, 12.8).

2 It is unspecified whether the implementation provides explicit definitions for such member function signatures, or for virtual destructors that can be generated by default.

17.3.2.3 Private members [lib.objects.within.classes]

1 Clauses 18 through 27 do not specify the representation of classes, and intentionally omit specification of class members (9.2). An implementation may define static or non-static class members, or both, as needed to implement the semantics of the member functions specified in clauses 18 through 27.

2 Objects of certain classes are sometimes required by the external specifications of their classes to store data, apparently in member objects. For the sake of exposition, some subclauses provide representative declarations, and semantic requirements, for private member objects of classes that meet the external specifications of the classes. The declarations for such member objects and the definitions of related member types are enclosed in a comment that ends with exposition only, as in:

//        streambuf*     sb;    exposition only

3 Any alternate implementation that provides equivalent external behavior is equally acceptable.

17.4 Library-wide requirements [lib.requirements]

1 This subclause specifies requirements that apply to the entire C++ Standard library. Clauses 18 through 27 specify the requirements of individual entities within the library.

2 The following subclauses describe the library's contents and organization (17.4.1), how well-formed C++ programs gain access to library entities (17.4.2), constraints on such programs (17.4.3), and constraints on conforming implementations (17.4.4).

17.4.1 Library contents and organization [lib.organization]

1 This subclause provides a summary of the entities defined in the C++ Standard Library. Subclause 17.4.1.1 provides an alphabetical listing of entities by type, while subclause 17.4.1.2 provides an alphabetical listing of library headers.

17.4.1.1 Library contents [lib.contents]

1 The C++ Standard Library provides definitions for the following types of entities: Macros, Values, Types, Templates, Classes, Functions, Objects.

2 All library entities except macros, operator new and operator delete are defined within the namespace std or namespaces nested within namespace std.

17.4.1.2 Headers [lib.headers]

1 The elements of the C++ Standard Library are declared or defined (as appropriate) in a header.158)

2 The C++ Standard Library provides 32 C++ headers, as shown in Table 11:

Table 11---C++ Library Headers
_ _______________________________________________________________________
 <algorithm>       <iomanip>      <list>         <ostream>       <streambuf>
 <bitset>          <ios>          <locale>       <queue>         <string>
 <complex>         <iosfwd>       <map>          <set>           <typeinfo>
 <deque>           <iostream>     <memory>       <sstream>       <utility>
 <exception>       <istream>      <new>          <stack>         <valarray>
 <fstream>         <iterator>     <numeric>      <stdexcept>     <vector>
_ <functional>     <limits>
_______________________________________________________________________ 

3 The facilities of the Standard C Library are provided in 18 additional headers, as shown in Table 12:

Table 12---C++ Headers for C Library Facilities
_ ______________________________________________________
  <cassert> <ciso646> <csetjmp> <cstdio>          <ctime>
  <cctype>    <climits> <csignal> <cstdlib> <cwchar>
  <cerrno>    <clocale> <cstdarg> <cstring> <cwctype>
_ <cfloat>    <cmath>     <cstddef>
 ______________________________________________________ 

4 Except as noted in clauses 18 through 27, the contents of each header cname shall be the same as that of the corresponding header name.h, as specified in ISO/IEC 9899:1990 Programming Languages C (Clause 7), or ISO/IEC:1990 Programming Languages---C AMENDMENT 1: C Integrity, (Clause 7), as appropriate, as if by inclusion. In the C++ Standard Library, however, the declarations and definitions (except for names which are defined as macros in C) are within namespace scope (3.3.5) of the namespace std.

5 Names which are defined as macros in C shall be defined as macros in the C++ Standard Library, even if C grants license for implementation as functions. [Note: the names defined as macros in C include the following: assert, errno, offsetof, setjmp, va_arg, va_end, and va_start. ---end note]

6 Names that are defined as functions in C shall be defined as functions in the C++ Standard Library.159)

7 D.5, Standard C library headers, describes the effects of using the name.h (C header) form in a C++ program.160)

158) A header is not necessarily a source file, nor are the sequences delimited by < and > in header names necessarily valid source file names (16.2). [back to text]

159) This disallows the practice, allowed in C, of providing a "masking macro" in addition to the function prototype. The only way to achieve equivalent "inline" behavior in C++ is to provide a definition as an extern inline function. [back to text]

160) The ".h" headers dump all their names into the global namespace, whereas the newer forms keep their names in namespace std. Therefore, the newer forms are the preferred forms for all uses except for C++ programs which are intended to be strictly compatible with C. [back to text]

17.4.1.3 Freestanding implementations [lib.compliance]

1 Two kinds of implementations are defined: hosted and freestanding (1.4). For a hosted implementation, this International Standard describes the set of available headers.

2 A freestanding implementation has an implementation-defined set of headers. This set shall include at least the following headers, as shown in Table 13:

Table 13---C++ Headers for Freestanding Implementations
_ _______________________________________________
_             Subclause                    Header(s)
_ _______________________________________________
 _______________________________________________
_ 18.1 Types                            <cstddef>
 _______________________________________________
_ 18.2 Implementation properties        <limits>
 _______________________________________________
_ 18.3 Start and termination            <cstdlib>
 _______________________________________________
_ 18.4 Dynamic memory management        <new>
 _______________________________________________
_ 18.5 Type identification              <typeinfo>
 _______________________________________________
_ 18.6 Exception handling               <exception>
 _______________________________________________
_ 18.7 Other runtime support            <cstdarg>
 _______________________________________________ 

3 The supplied version of the header <cstdlib> shall declare at least the functions abort(), atexit(), and exit() (18.3).

17.4.2 Using the library [lib.using]

1 This subclause describes how a C++ program gains access to the facilities of the C++ Standard Library. 17.4.2.1 describes effects during translation phase 4, while 17.4.2.2 describes effects during phase 8 (2.1).

17.4.2.1 Headers [lib.using.headers]

1 The entities in the C++ Standard Library are defined in headers, whose contents are made available to a translation unit when it contains the appropriate #include preprocessing directive (16.2).

2 A translation unit may include library headers in any order (clause 2). Each may be included more than once, with no effect different from being included exactly once, except that the effect of including either <cassert> or <assert.h> depends each time on the lexically current definition of NDEBUG.161)

3 A translation unit shall include a header only outside of any external declaration or definition, and shall include the header lexically before the first reference to any of the entities it declares or first defines in that translation unit.

161) This is the same as the Standard C library. [back to text]

17.4.2.2 Linkage [lib.using.linkage]

1 Entities in the C++ Standard Library have external linkage (3.5). Unless otherwise specified, objects and functions have the default extern "C++" linkage (7.5).

2 It is unspecified whether a name from the Standard C library declared with external linkage has either extern "C" or extern "C++" linkage.162)

3 Objects and functions defined in the library and required by a C++ program are included in the program prior to program startup. SEE ALSO: replacement functions (17.4.3.4), run-time changes (17.4.3.5).

162) The only reliable way to declare an object or function signature from the Standard C library is by including the header that declares it, notwithstanding the latitude granted in subclause 7.1.7 of the C Standard. [back to text]

17.4.3 Constraints on programs [lib.constraints]

1 This subclause describes restrictions on C++ programs that use the facilities of the C++ Standard Library. The following subclauses specify constraints on the program's namespace (17.4.3.1), its use of headers (17.4.3.2), classes derived from standard library classes (17.4.3.3), definitions of replacement functions (17.4.3.4), and installation of handler functions during execution (17.4.3.5).

17.4.3.1 Reserved names [lib.reserved.names]

1 It is undefined for a C++ program to add declarations or definitions to namespace std or namespaces within namespace std unless otherwise specified. A program may add template specializations for any standard library template to namespace std. Such a specialization (complete or partial) of a standard library template results in undefined behavior unless the declaration depends on a user-defined name of external linkage and unless the specialization meets the standard library requirements for the original template.163)

2 The C++ Standard Library reserves the following kinds of names:

3 If the program declares or defines a name in a context where it is reserved, other than as explicitly allowed by this clause, the behavior is undefined.

163) Any library code that instantiates other library templates must be prepared to work adequately with any user-supplied specialization that meets the minimum requirements of the Standard. [back to text]
17.4.3.1.1 Macro names [lib.macro.names]

1 Each name defined as a macro in a header is reserved to the implementation for any use if the translation unit includes the header.164)

2 A translation unit that includes a header shall not contain any macros that define names declared or defined in that header. Nor shall such a translation unit define macros for names lexically identical to keywords.

164) It is not permissible to remove a library macro definition by using the #undef directive. [back to text]
17.4.3.1.2 Global names [lib.global.names]

1 Certain sets of names and function signatures are always reserved to the implementation:

165) Such names are also reserved in namespace ::std (17.4.3.1). [back to text]
17.4.3.1.3 External linkage [lib.extern.names]

1 Each name declared as an object with external linkage in a header is reserved to the implementation to designate that library object with external linkage,166) both in namespace std and in the global namespace.

2 Each global function signature declared with external linkage in a header is reserved to the implementation to designate that function signature with external linkage.167)

3 Each name having two consecutive underscores (2.11) is reserved to the implementation for use as a name with both extern "C" and extern "C++" linkage.

4 Each name from the Standard C library declared with external linkage is reserved to the implementation for use as a name with extern "C" linkage, both in namespace std and in the global namespace.

5 Each function signature from the Standard C library declared with external linkage is reserved to the implementation for use as a function signature with both extern "C" and extern "C++" linkage,168) or as a name of namespace scope in the global namespace.

166) The list of such reserved names includes errno, declared or defined in <cerrno>. [back to text]

167) The list of such reserved function signatures with external linkage includes setjmp(jmp_buf), declared or defined in <csetjmp>, and va_end(va_list), declared or defined in <cstdarg>. [back to text]

168) The function signatures declared in <cwchar> and <cwctype> are always reserved, notwithstanding the restrictions imposed in subclause 4.5.1 of Amendment 1 to the C Standard for these headers. [back to text]

17.4.3.1.4 Types [lib.extern.types]

1 For each type T from the Standard C library,169) the types ::T and std::T are reserved to the implementation and, when defined, ::T shall be identical to std::T.

169) These types are clock_t, div_t, FILE, fpos_t, lconv, ldiv_t, mbstate_t, ptrdiff_t, sig_atomic_t, size_t, time_t, tm, va_list, wctrans_t, wctype_t, and wint_t. [back to text]

17.4.3.2 Headers [lib.alt.headers]

1 If a file with a name equivalent to the derived file name for one of the C++ Standard Library headers is not provided as part of the implementation, and a file with that name is placed in any of the standard places for a source file to be included (16.2), the behavior is undefined.

17.4.3.3 Derived classes [lib.derived.classes]

1 Virtual member function signatures defined for a base class in the C++ Standard library may be overridden in a derived class defined in the program (10.3).

17.4.3.4 Replacement functions [lib.replacement.functions]

1 Clauses 18 through 27 describe the behavior of numerous functions defined by the C++ Standard Library. Under some circumstances, however, certain of these function descriptions also apply to replacement functions defined in the program (17.1).

2 A C++ program may provide the definition for any of eight dynamic memory allocation function signatures declared in header <new> (3.7.3, clause 18):

3 The program's definitions are used instead of the default versions supplied by the implementation (8.4). Such replacement occurs prior to program startup (3.2, 3.6).

17.4.3.5 Handler functions [lib.handler.functions]

1 The C++ Standard Library provides default versions of the following handler functions (clause 18):

2 A C++ program may install different handler functions during execution, by supplying a pointer to a function defined in the program or the library as an argument to (respectively):

SEE ALSO: subclauses 18.4.2, Storage allocation errors, and 18.6, Exception handling.

17.4.3.6 Other functions [lib.res.on.functions]

1 In certain cases (replacement functions, handler functions, operations on types used to instantiate standard library template components), the C++ Standard Library depends on components supplied by a C++ program. If these components do not meet their requirements, the Standard places no requirements on the implementation.

2 In particular, the effects are undefined in the following cases:

17.4.3.7 Function arguments [lib.res.on.arguments]

1 Each of the following statements applies to all arguments to functions defined in the C++ Standard Library, unless explicitly stated otherwise.

17.4.3.8 Required paragraph [lib.res.on.required]

1 Violation of the preconditions specified in a function's Required behavior paragraph results in undefined behavior unless the function's Throws paragraph specifies throwing an exception when the precondition is violated.

17.4.4 Conforming implementations [lib.conforming]

1 This subclause describes the constraints upon, and latitude of, implementations of the C++ Standard library. The following subclauses describe an implementation's use of headers (17.4.4.1), macros (17.4.4.2), global functions (17.4.4.3), member functions (17.4.4.4), reentrancy (17.4.4.5), access specifiers (17.4.4.6), class derivation (17.4.4.7), and exceptions (17.4.4.8).

17.4.4.1 Headers [lib.res.on.headers]

1 A C++ header may include other C++ headers.170)

2 Certain types and macros are defined in more than one header. For such an entity, a second or subsequent header that also defines it may be included after the header that provides its initial definition (3.2).

3 Header inclusion is limited as follows:

170) C++ headers must include a C++ header that contains any needed definition (3.2). [back to text]

17.4.4.2 Restrictions on macro definitions [lib.res.on.macro.definitions]

1 The names or global function signatures described in 17.4.1.1 are reserved to the implementation.

2 All object-like macros defined by the Standard C library and described in this clause as expanding to integral constant expressions are also suitable for use in #if preprocessing directives, unless explicitly stated otherwise.

17.4.4.3 Global functions [lib.global.functions]

1 It is unspecified whether any global functions in the C++ Standard Library are defined as inline (7.1.2).

2 A call to a global function signature described in Clauses 18 through 27 behaves the same as if the implementation declares no additional global function signatures.171)

3 A global function cannot be declared by the implementation as taking additional default arguments.

171) A valid C++ program always calls the expected library global function. An implementation may also define additional global functions that would otherwise not be called by a valid C++ program. [back to text]

17.4.4.4 Member functions [lib.member.functions]

1 It is unspecified whether any member functions in the C++ Standard Library are defined as inline (7.1.2).

2 An implementation can declare additional non-virtual member function signatures within a class:

3 A call to a member function signature described in the C++ Standard library behaves the same as if the implementation declares no additional member function signatures.173)

172) Hence, taking the address of a member function has an unspecified type. [back to text]

173) A valid C++ program always calls the expected library member function, or one with equivalent behavior. An implementation may also define additional member functions that would otherwise not be called by a valid C++ program. [back to text]

17.4.4.5 Reentrancy [lib.reentrancy]

1 Which of the functions in the C++ Standard Library are not reentrant subroutines is implementationdefined.

17.4.4.6 Protection within classes [lib.protection.within.classes]

1 It is unspecified whether a function signature or class described in clauses 18 through 27 is a friend of another class in the C++ Standard Library.

17.4.4.7 Derived classes [lib.derivation]

1 It is unspecified whether a class in the C++ Standard Library is itself derived from other classes (with names reserved to the implementation).

2 Certain classes defined in the C++ Standard Library are derived from other classes in the C++ Standard Library:

3 In any case:

174) An implicit exception to this rule are types described as synonyms for basic integral types, such as size_t (18.1) and streamoff (27.4.1). [back to text]

17.4.4.8 Restrictions on exception handling [lib.res.on.exception.handling]

1 Any of the functions defined in the C++ Standard Library can report a failure by throwing an exception of the type(s) described in their Throws: paragraph and/or their exception-specification (15.4). An implementation may strengthen the exception-specification for a function by removing listed exceptions.175)

2 None of the functions from the Standard C library shall report an error by throwing an exception,176) unless it calls a program-supplied function that throws an exception.177)

3 No destructor operation defined in the C++ Standard Library will throw an exception. Any other functions defined in the C++ Standard Library that do not have an exception-specification may throw implementation-defined exceptions unless otherwise specified.178) An implementation may strengthen this implicit exception-specification by adding an explicit one.179)

175) That is, an implementation of the function will have an explicit exception-specification that lists fewer exceptions than those specified in this International Standard. It may not, however, change the types of exceptions listed in the exception-specficiation from those specified, nor add others. [back to text]

176) That is, the C library functions all have a throw() exception-specification. This allows implementations to make performance optimizations based on the absence of exceptions at runtime. [back to text]

177) The functions qsort() and bsearch() (25.4) meet this condition. [back to text]

178) In particular, they can report a failure to allocate storage by throwing an exception of type bad_alloc, or a class derived from bad_alloc (18.4.2.1). Library implementations are encouraged (but not required) to report errors by throwing exceptions from (or derived from) the standard exception classes (18.4.2.1, 18.6, 19.1). [back to text]

179) That is, an implementation may provide an explicit exception-specification that defines the subset of ``any'' exceptions thrown by that function. This implies that the implementation may list implementation-defined types in such an exception-specification. [back to text]