In C++, the C++ Standard Library is a collection of classes and functions, which are written in the core language and part of the C++ ISO Standard itself.[1] The C++ Standard Library provides several generic containers, functions to utilise and manipulate these containers, function objects, generic strings and streams (including interactive and file I/O), support for some language features, and everyday functions for tasks such as finding the square root of a number. The C++ Standard Library also incorporates 18 headers of the ISO C90 C standard library ending with ".h", but their use is deprecated.[2] All other headers in the C++ Standard Library do not end in ".h". Features of the C++ Standard Library are declared within the std
namespace.
The C++ Standard Library is based upon conventions introduced by the Standard Template Library (STL). Although the C++ Standard Library and the STL share many features, neither is a strict superset of the other. In particular, the C++ Standard Library has also been influenced[3] by the work of Alexander Stepanov and Meng Lee.[4]
The C++ Standard Library underwent ISO standardisation as part of the C++ ISO Standardisation effort, and is undergoing further work[5] regarding standardisation of expanded functionality.
C++ Standard Library |
---|
Standard Template Library |
|
C standard library |
|
Contents |
The following files contain the declarations of the C++ Standard Library.
std::array
, a container for a fixed sized array.std::bitset
, a bit array.std::deque
, a double-ended queue.std::forward_list
, a singly linked list.std::list
, a doubly linked list.std::map
and std::multimap
, sorted associative array and multimap.std::queue
, a single-ended queue.std::set
and std::multiset
, sorted associative containers or sets.std::stack
, a stack.std::unordered_map
and std::unordered_multimap
, hash tables.std::unordered_set
and std::unordered_multiset
.std::vector
, a dynamic array.std::auto_ptr
.std::logic_error
and std::runtime_error
, both derived from std::exception
.std::tuple
, a tuple.std::pair
, for working with pairs (two-member tuples) of objects.std::istream
and other supporting classes for input.std::ostream
and other supporting classes for output.std::sstream
and other supporting classes for string manipulation.std::complex
and associated functions for working with complex numbers.std::valarray
, an array class optimized for numeric processing.std::exception
, the base class of all exceptions thrown by the Standard Library.std::numeric_limits
, used for describing properties of fundamental numeric types.new
and delete
and other functions and types composing the fundamentals of C++ memory management.Each header from the C Standard Library is included in the C++ Standard Library under a different name, generated by removing the .h, and adding a 'c' at the start; for example, 'time.h' becomes 'ctime'. The only difference between these headers and the traditional C Standard Library headers is that where possible the functions should be placed into the std:: namespace (although few compilers actually do this). In ISO C, functions in the standard library are allowed to be implemented by macros, which is not allowed by ISO C++.