Everipedia Logo
Everipedia is now IQ.wiki - Join the IQ Brainlist and our Discord for early access to editing on the new platform and to participate in the beta testing.
C++ Standard Library

C++ Standard Library

In the C++ programming language, 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]

Overview

The C++ Standard Library provides several generic containers, functions to utilize and manipulate these containers, function objects, generic strings and streams (including interactive and file I/O), support for some language features, and functions for everyday 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.[1] No other headers in the C++ Standard Library 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), and has been influenced by research in generic programming and developers of the STL such as Alexander Stepanov and Meng Lee.[3][4] Although the C++ Standard Library and the STL share many features, neither is a strict superset of the other.

A noteworthy feature of the C++ Standard Library is that it not only specifies the syntax and semantics of generic algorithms, but also places requirements on their performance.[5] These performance requirements often correspond to a well-known algorithm, which is expected but not required to be used.

In most cases this requires linear time O(n) or linearithmic time O(n log n), but in some cases higher bounds are allowed, such as quasilinear time O(n log2 n) for stable sort (to allow in-place merge sort). Previously, sorting was only required to take O(n log n) on average, allowing the use of quicksort, which is fast in practice but has poor worst-case performance, but introsort was introduced to allow both fast average performance and optimal worst-case complexity, and as of C++11, sorting is guaranteed to be at worst linearithmic. In other cases requirements remain laxer, such as selection, which is only required to be linear on average (as in quickselect),[6] not requiring worst-case linear as in introselect.

The C++ Standard Library underwent ISO standardization as part of the C++ ISO Standardization effort, and is undergoing further work[7] regarding standardization of expanded functionality.

Implementations

At CppCon 2019 on September 16th, 2019, Microsoft announced releasing their implementation of the C++ Standard Library (also known as the STL) as open source.[8] It is hosted on GitHub and licensed under the Apache License 2.0 with LLVM Exception.[9][10]

Standard headers

The following files contain the declarations of the C++ Standard Library.

Containers

New inand.Provides the container class template, a container for a fixed sized array.Provides the specialized container class, a.Provides the container class template, a.<forward_list>New inand.Provides the container class template, a.Provides the container class template, a.Provides the container class templatesand, sortedand.Provides the container adapter class, a single-ended, and, a.Provides the container class templatesand, sorted associative containers or.Provides the container adapter class, a.<unordered_map>New inand.Provides the container class templateand,.<unordered_set>New inand.Provides the container class templateand.Provides the container class template, a.

General

Provides definitions of many container.
Provides time elements, such as,, and clocks.
Provides several, designed for use with the standard algorithms.Provides classes and templates for working with.
Provides facilities forin C++, including the class template.Contains standard exception classes such asand, both derived from.New inand TR1.Provides a class template, a.Provides the template class, for working with object pairs (two-member), and the namespace, for easier operator overloading.

Localization

Defines classes and declares functions that encapsulate and manipulate the information peculiar to a.Provides code conversion facets for various character encodings.

Strings

Provides the C++ standardclasses and templates.New in.Provides utilities for pattern matching strings using.

Streams and input/output

Provides facilities for file-based input and output.See.Provides facilities to manipulate output formatting, such as theused when formatting integers and theofvalues.Provides several types and functions basic to the operation of iostreams.Providesof several I/O-related class templates.Provides C++ input and output fundamentals.See.Provides the template classand other supporting classes for input.Provides the template classand other supporting classes for output.Provides the template classand other supporting classes for string manipulation.Provides reading and writing functionality to/from certain types of character sequences, such as external files or strings.

Language support

Provides several types and functions related to, including, the base class of all exceptions thrown by the Standard Library.Provides the template class, used for describing properties of fundamental numeric types.Provides operatorsandand other functions and types composing the fundamentals of C++.Provides facilities for working with C++.

Thread support library

New in.Provide class and namespace for working with threads.New in.30.4-1.This section provides mechanisms for mutual exclusion: mutexes, locks, and call once.<condition_variable>New in.30.5-1.Condition variables provide synchronization primitives used to block a thread until notified by some other thread that some condition is met or until a system time is reached.New in.30.6.1-1.Describes components that a C++ program can use to retrieve in one thread the result (value or exception) from a function that has run in the same thread or another thread.

Numerics library

Components that C++ programs may use to perform seminumerical operations.

The header defines a class template, and numerous functions for representing and manipulating complex numbers.Facility for generating (pseudo-)random numbersDefines five class templates (valarray, slice_array, gslice_array, mask_array, and indirect_array), two classes (slice and gslice),and a series of related function templates for representing and manipulating arrays of values.Generalized numeric operations.

C standard library

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. In ISO

C, functions in the standard library are allowed to be implemented by macros, which is not allowed by ISO C++.

See also

  • Apache C++ Standard Library

  • Boost (C++ libraries)

  • C POSIX library

  • C standard library

  • Standard library

  • C++ Technical Report 1

References

[1]
Citation Linkopenlibrary.orgISO/IEC 14882:2003(E) Programming Languages — C++ §17-27
Sep 20, 2019, 7:24 PM
[3]
Citation Linkopenlibrary.orgBjarne Stroustrup. The Design and Evolution of C++ §8.5. Addison Wesley. ISBN 0-201-54330-3.
Sep 20, 2019, 7:24 PM
[4]
Citation Linkwww.hpl.hp.comAlexander Stepanov, Meng Lee (1 August 1994). "The Standard Template Library". HP Labs. Retrieved 22 October 2017.
Sep 20, 2019, 7:24 PM
[5]
Citation Linkwww.cs.rpi.edu"Generic Algorithms", David Musser
Sep 20, 2019, 7:24 PM
[6]
Citation Linken.cppreference.com"std::nth_element". cppreference.com. Retrieved 20 March 2018.
Sep 20, 2019, 7:24 PM
[7]
Citation Linkwww.open-std.org"JTC1/SC22/WG21 - The C++ Standards Committee". ISO/IEC. Retrieved 7 July 2009.
Sep 20, 2019, 7:24 PM
[8]
Citation Linkdevblogs.microsoft.comhttps://devblogs.microsoft.com/cppblog/open-sourcing-msvcs-stl/
Sep 20, 2019, 7:24 PM
[9]
Citation Linkgithub.comhttps://github.com/microsoft/STL
Sep 20, 2019, 7:24 PM
[10]
Citation Linkgithub.comhttps://github.com/microsoft/STL/blob/master/LICENSE.txt
Sep 20, 2019, 7:24 PM
[11]
Citation Linkwww.cppstdlib.comThe C++ Standard Library - A Tutorial and Reference
Sep 20, 2019, 7:24 PM
[12]
Citation Linkcppcoders.comC++ Standard Library Quick Reference
Sep 20, 2019, 7:24 PM
[13]
Citation Linken.cppreference.comC++ Standard Library reference
Sep 20, 2019, 7:24 PM
[14]
Citation Linkdocs.microsoft.comMicrosoft C++ Standard Library Reference
Sep 20, 2019, 7:24 PM
[15]
Citation Linkwww.roguewave.comRogue Wave SourcePro C++ documentation
Sep 20, 2019, 7:24 PM
[16]
Citation Linkwiki.apache.orgApache C++ Standard Library Wiki
Sep 20, 2019, 7:24 PM
[17]
Citation Linkstdcxx.apache.orgretired 15 May 2014
Sep 20, 2019, 7:24 PM
[18]
Citation Linkwww.stlport.orgSTLport C++ Standard Library documentation
Sep 20, 2019, 7:24 PM
[19]
Citation Linkgcc.gnu.orgThe GNU C++ Library online documentation
Sep 20, 2019, 7:24 PM
[20]
Citation Linklibcxx.llvm.orgLLVM/Clang C++ Standard Library documentation
Sep 20, 2019, 7:24 PM
[38]
Citation Linken.wikipedia.orgThe original version of this page is from Wikipedia, you can edit the page right here on Everipedia.Text is available under the Creative Commons Attribution-ShareAlike License.Additional terms may apply.See everipedia.org/everipedia-termsfor further details.Images/media credited individually (click the icon for details).
Sep 20, 2019, 7:24 PM