The standard library has 51 headers, each containing a set of macro, function, type, and object declarations. A header is sometimes called a header file, but that phrase is misleading. An implementation does not need to implement headers as external files, although it is often simplest to think of a header as a file that contains macro, type, and function declarations.
Almost all the names declared in the standard library are in the std namespace. Macros, of course, are not in any namespace, so it is important that you know which names are macros and which are not. The detailed descriptions in Chapter 13 tell you this information. The only other names that are outside the std namespace are the global operator new and operator delete functions, declared in the <new> header.
To use the standard library, you must #include the desired header or headers. Some implementations #include headers within other headers (e.g., <set> might #include <iterator>). The headers that a vendor includes within a header vary from one implementation to another, so code that compiles successfully with one vendor's environment might not compile in a different environment. The solution is to get in the habit of including all the headers you need.
|
You must not add any declarations to the std namespace, although you can specialize templates that are declared in std. When you add your own specialization, you must obey all the constraints specified for the template, and the specialization must depend on at least one user-defined name that has external linkage. Otherwise, the behavior is undefined.
The following are brief descriptions of the contents of each header. The headers inherited from the C standard are marked as "C header." Some of these headers have improved C++ equivalents, which are also shown. For complete descriptions of these headers, see Chapter 13.
Standard algorithms for copying, searching, sorting, and otherwise operating on iterators and containers. See Chapter 10 for more information about the standard algorithms.
Class template to hold a fixed-sized sequence of bits.
Runtime assertion-checking; C header.
Character classification and case conversion; C header (see also <locale>).
Error codes; C header.
Limits of floating-point types; C header (see also <limits>).
Empty header because C declarations are incorporated in the C++ language; C header.
Limits of integer types; C header (see also <limits>).
Locale-specific information; C header (see also <locale>).
Mathematical functions; C header.
Complex numbers.
Nonlocal goto; C header.
Asynchronous signals; C header.
Macros to help implement functions that take a variable number of arguments; C header.
Miscellaneous standard definitions; C header.
Standard input and output; C header (see also <iostream> and related headers).
Miscellaneous functions and related declarations; C header.
String-handling functions; C header (see also <string>).
Date and time functions and types; C header.
Wide character functions, including I/O; C header (see also <locale>, <iostream>, <string>, and other I/O-related headers).
Wide character classification and case conversion; C header (see also <locale>).
Deque (double-ended queue) standard container.
Base exception class and functions related to exception-handling.
File-based stream I/O.
Function objects; typically used with standard algorithms.
I/O manipulators; used with standard I/O streams.
Base class declarations for all I/O streams.
Forward declarations for I/O objects.
Declarations of standard I/O objects.
Input streams and input/output streams.
Additional iterators for working with standard containers and algorithms. See Chapter 10 for more information.
Limits of numerical types.
Standard linked list container.
Locale-specific information for formatting and parsing numbers, dates, times, and currency values, plus character-related functions for classifying, converting, and comparing characters and strings.
Associative map (sometimes called a dictionary) standard container.
Allocators, algorithms for uninitialized memory, and smart pointers (auto_ptr).
Global operator new and operator delete and other functions related to managing dynamic memory.
Numerical algorithms.
Output streams.
Queue and priority queue container adapters.
Associative set container.
String-based I/O streams.
Stack container adapter.
Standard exception classes.
Low-level stream buffers; used by high-level I/O streams.
Strings and wide-character strings.
String streams that work with character arrays (see also <sstream>).
Runtime type information.
Miscellaneous templates, such as pair, most often used with standard containers and algorithms.
Numerical arrays.
Vector (array-like) standard container.