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.
Detailed specifications for each of the components in the library are in Clauses [language.support]–[thread], as shown in Table 15.
Table
15— Library categories
The diagnostics library provides a consistent framework for reporting errors in a C++ program, including predefined exception classes.
The general utilities library includes components used by other library elements, such as a predefined storage allocator for dynamic storage management, and components used as infrastructure in C++ programs, such as tuples, function wrappers, and time facilities.
The strings library provides support for manipulating text represented as sequences of type char, sequences of type char16_t, sequences of type char32_t, sequences of type wchar_t, and sequences of any other character-like type.
The containers, iterators, and algorithms libraries provide a C++ program with access to a subset of the most widely used algorithms and data structures.
The numerics library provides numeric algorithms and complex number components that extend support for numeric processing. The valarray component provides support for n-at-a-time processing, potentially implemented as parallel operations on platforms that support such processing. The random number component provides facilities for generating pseudo-random numbers.
The input/output library provides the iostream components that are the primary mechanism for C++ program input and output. They can be used with other elements of the library, particularly strings, locales, and iterators.
The thread support library provides components to create and manage threads, including mutual exclusion and interthread communication.
20.3 Definitions [definitions][ Note: Clause [intro.defs] defines additional terms used elsewhere in this International Standard. — end note ]
20.3.1 arbitrary-positional stream [defns.arbitrary.stream]a stream (described in Clause [input.output]) that can seek to any integral position within the length of the stream
[ Note: Every arbitrary-positional stream is also a repositional stream. — end note ]
⟨Clauses [strings], [localization], [input.output], and [re]⟩ any object which, when treated sequentially, can represent text
[ Note: The term does not mean only char, char16_t, char32_t, and wchar_t objects, but any value that can be represented by a type that provides the definitions specified in these Clauses. — end note ]
a class or a type used to represent a character
[ Note: It is used for one of the template parameters of the string, iostream, and regular expression class templates. A character container type is a POD type. — end note ]
a group of library entities directly related as members, parameters, or return types
[ Note: For example, the class template basic_string and the non-member function templates that operate on strings are referred to as the string component. — end note ]
one or more threads are unable to continue execution because each is blocked waiting for one or more of the others to satisfy some condition
20.3.11 handler function [defns.handler]a non-reserved function whose definition may be provided by a C++ program
[ Note: 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 [language.support]). — end note ]
templates, defined in Clause [input.output], that take two template arguments
[ Note: The arguments are named charT and traits. The argument charT is a character container class, and the argument traits is a class which defines additional characteristics and functions of the character type represented by charT necessary to implement the iostream class templates. — end note ]
an object type, a function type that does not have cv-qualifiers or a ref-qualifier, or a reference type [ Note: The term describes a type to which a reference can be created, including reference types. — end note ]
20.3.19 replacement function [defns.replacement]a non-reserved function whose definition is provided by a C++ program
[ Note: 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 ([lex.phases]) and resolving the definitions of all translation units ([basic.link]). — end note ]
a description of replacement function and handler function semantics applicable to both the behavior provided by the implementation and the behavior of any such function definition in the program
[ Note: If such a function defined in a C++ program fails to meet the required behavior when it executes, the behavior is undefined. — end note ]
a function, specified as part of the C++ standard library, that must be defined by the implementation
[ Note: If a C++ program provides a definition for any reserved function, the results are undefined. — end note ]
an algorithm that preserves, as appropriate to the particular algorithm, the order of elements
[ Note: Requirements for stable algorithms are given in [algorithm.stable]. — end note ]
a class that encapsulates a set of types and functions necessary for class templates and function templates to manipulate objects of types for which they are instantiated
20.3.25 valid but unspecified state [defns.valid]a value of an object that is not specified except that the object's invariants are met and operations on the object behave as specified for its type
[ Example: If an object x of type std::vector<int> is in a valid but unspecified state, x.empty() can be called unconditionally, and x.front() can be called only if x.empty() returns false. — end example ]
This subclause specifies requirements that apply to the entire C++ standard library. Clauses [language.support] through [thread] and Annex [depr] specify the requirements of individual entities within the library.
Requirements specified in terms of interactions between threads do not apply to programs having only a single thread of execution.
Within this subclause, [organization] describes the library's contents and organization, [using] describes how well-formed C++ programs gain access to library entities, [utility.requirements] describes constraints on types and functions used with the C++ standard library, [constraints] describes constraints on well-formed C++ programs, and [conforming] describes constraints on conforming implementations.
20.5.1 Library contents and organization [organization][contents] describes the entities and macros defined in the C++ standard library. [headers] lists the standard library headers and some constraints on those headers. [compliance] lists requirements for a freestanding implementation of the C++ standard library.
20.5.1.1 Library contents [contents]The C++ standard library provides definitions for the entities and macros described in the synopses of the C++ standard library headers ([headers]).
All library entities except operator new and operator delete are defined within the namespace std or namespaces nested within namespace std.166 It is unspecified whether names declared in a specific namespace are declared directly in that namespace or in an inline namespace inside that namespace.167
Whenever a name x defined in the standard library is mentioned, the name x is assumed to be fully qualified as ::std::x, unless explicitly described otherwise. For example, if the Effects: section for library function F is described as calling library function G, the function ::std::G is meant.
20.5.1.3 Freestanding implementations [compliance]Two kinds of implementations are defined: hosted and freestanding ([intro.compliance]). For a hosted implementation, this International Standard describes the set of available headers.
A freestanding implementation has an implementation-defined set of headers. This set shall include at least the headers shown in Table 19.
Table
19— C++ headers for freestanding implementations
The supplied version of the header <cstdlib> shall declare at least the functions abort, atexit, at_quick_exit, exit, and quick_exit ([support.start.term]). The other headers listed in this table shall meet the same requirements as for a hosted implementation.
20.5.2 Using the library [using] 20.5.2.3 Linkage [using.linkage]Entities in the C++ standard library have external linkage. Unless otherwise specified, objects and functions have the default extern "C++" linkage ([dcl.link]).
Whether a name from the C standard library declared with external linkage has extern "C" or extern "C++" linkage is implementation-defined. It is recommended that an implementation use extern "C++" linkage for this purpose.174
Objects and functions defined in the library and required by a C++ program are included in the program prior to program startup.
20.5.3 Requirements on types and expressions [utility.requirements] 20.5.3.1 Template argument requirements [utility.arg.requirements]The template definitions in the C++ standard library refer to various named requirements whose details are set out in Tables 20–27. In these tables, T is an object or reference type to be supplied by a C++ program instantiating a template; a, b, and c are values of type (possibly const) T; s and t are modifiable lvalues of type T; u denotes an identifier; rv is an rvalue of type T; and v is an lvalue of type (possibly const) T or an rvalue of type const T.
In general, a default constructor is not required. Certain container class member function signatures specify T() as a default argument. T() shall be a well-defined expression ([dcl.init]) if one of those signatures is called using the default argument.
Table
20—
EqualityComparablerequirements
For all a, a == a.
If a == b, then b == a.
If a == b and b == c, then a == c.
Table
21—
LessThanComparablerequirements
Table
22—
DefaultConstructiblerequirements
Table
23—
MoveConstructiblerequirements
Table
24—
CopyConstructiblerequirements (in addition to
MoveConstructible)
Table
25—
MoveAssignablerequirements
Table
26—
CopyAssignablerequirements (in addition to
MoveAssignable)
Table
27—
Destructiblerequirements
This subclause provides definitions for swappable types and expressions. In these definitions, let t denote an expression of type T, and let u denote an expression of type U.
An object t is swappable with an object u if and only if:
the expressions swap(t, u) and swap(u, t) are valid when evaluated in the context described below, and
these expressions have the following effects:
the object referred to by t has the value originally held by u and
the object referred to by u has the value originally held by t.
The context in which swap(t, u) and swap(u, t) are evaluated shall ensure that a binary non-member function named “swap” is selected via overload resolution on a candidate set that includes:
the two swap function templates defined in <utility> and
the lookup set produced by argument-dependent lookup.
[ Note: If T and U are both fundamental types or arrays of fundamental types and the declarations from the header <utility> are in scope, the overall lookup set described above is equivalent to that of the qualified name lookup applied to the expression std::swap(t, u) or std::swap(u, t) as appropriate. — end note ]
[ Note: It is unspecified whether a library component that has a swappable requirement includes the header <utility> to ensure an appropriate evaluation context. — end note ]
An rvalue or lvalue t is swappable if and only if t is swappable with any rvalue or lvalue, respectively, of type T.
A type X satisfying any of the iterator requirements satisfies the requirements of ValueSwappable if, for any dereferenceable object x of type X, *x is swappable.
[ Example: User code can ensure that the evaluation of swap calls is performed in an appropriate context under the various conditions as follows:
#include <utility> template <class T, class U> void value_swap(T&& t, U&& u) { using std::swap; swap(std::forward<T>(t), std::forward<U>(u)); } template <class T> void lv_swap(T& t1, T& t2) { using std::swap; swap(t1, t2); } namespace N { struct A { int m; }; struct Proxy { A* a; }; Proxy proxy(A& a) { return Proxy{ &a }; } void swap(A& x, Proxy p) { std::swap(x.m, p.a->m); } void swap(Proxy p, A& x) { swap(x, p); } } int main() { int i = 1, j = 2; lv_swap(i, j); assert(i == 2 && j == 1); N::A a1 = { 5 }, a2 = { -5 }; value_swap(a1, proxy(a2)); assert(a1.m == -5 && a2.m == 5); }
— end example ]
20.5.3.3 NullablePointer requirements [nullablepointer.requirements]A NullablePointer type is a pointer-like type that supports null values. A type P meets the requirements of NullablePointer if:
P satisfies the requirements of EqualityComparable, DefaultConstructible, CopyConstructible, CopyAssignable, and Destructible,
lvalues of type P are swappable,
the expressions shown in Table 28 are valid and have the indicated semantics, and
P satisfies all the other requirements of this subclause.
A value-initialized object of type P produces the null value of the type. The null value shall be equivalent only to itself. A default-initialized object of type P may have an indeterminate value. [ Note: Operations involving indeterminate values may cause undefined behavior. — end note ]
No operation which is part of the NullablePointer requirements shall exit via an exception.
In Table 28, u denotes an identifier, t denotes a non-const lvalue of type P, a and b denote values of type (possibly const) P, and np denotes a value of type (possibly const) std::nullptr_t.
Table
28—
NullablePointerrequirements
Given Key is an argument type for function objects of type H, in Table 29 h is a value of type (possibly const) H, u is an lvalue of type Key, and k is a value of a type convertible to (possibly const) Key.
Table
29—
Hashrequirements
The library describes a standard set of requirements for allocators, which are class-type objects that encapsulate the information about an allocation model. This information includes the knowledge of pointer types, the type of their difference, the type of the size of objects in this allocation model, as well as the memory allocation and deallocation primitives for it. All of the string types, containers (except array), string buffers and string streams (Clause [input.output]), and match_results are parameterized in terms of allocators.
The class template allocator_traits supplies a uniform interface to all allocator types. Table 30 describes the types manipulated through allocators. Table 31 describes the requirements on allocator types and thus on types used to instantiate allocator_traits. A requirement is optional if the last column of Table 31 specifies a default for a given expression. Within the standard library allocator_traits template, an optional requirement that is not supplied by an allocator is replaced by the specified default expression. A user specialization of allocator_traits may provide different defaults and may provide defaults for different requirements than the primary template. Within Tables 30 and 31, the use of move and forward always refers to std::move and std::forward, respectively.
Table
30— Descriptive variable definitions
Table
31— Allocator requirements
Note A: The member class template rebind in the table above is effectively a typedef template. [ Note: In general, if the name Allocator is bound to SomeAllocator<T>, then Allocator::rebind<U>::other is the same type as SomeAllocator<U>, where SomeAllocator<T>::value_type is T and SomeAllocator<U>::value_type is U. — end note ] If Allocator is a class template instantiation of the form SomeAllocator<T, Args>, where Args is zero or more type arguments, and Allocator does not supply a rebind member template, the standard allocator_traits template uses SomeAllocator<U, Args> in place of Allocator::rebind<U>::other by default. For allocator types that are not template instantiations of the above form, no default is provided.
Note B: If X::propagate_on_container_copy_assignment::value is true, X shall satisfy the CopyAssignable requirements and the copy operation shall not throw exceptions. If X::propagate_on_container_move_assignment::value is true, X shall satisfy the MoveAssignable requirements and the move operation shall not throw exceptions. If X::propagate_on_container_swap::value is true, lvalues of type X shall be swappable and the swap operation shall not throw exceptions.
An allocator type X shall satisfy the requirements of CopyConstructible. The X::pointer, X::const_pointer, X::void_pointer, and X::const_void_pointer types shall satisfy the requirements of NullablePointer. No constructor, comparison function, copy operation, move operation, or swap operation on these pointer types shall exit via an exception. X::pointer and X::const_pointer shall also satisfy the requirements for a random access iterator and of a contiguous iterator.
Let x1 and x2 denote objects of (possibly different) types X::void_pointer, X::const_void_pointer, X::pointer, or X::const_pointer. Then, x1 and x2 are equivalently-valued pointer values, if and only if both x1 and x2 can be explicitly converted to the two corresponding objects px1 and px2 of type X::const_pointer, using a sequence of static_casts using only these four types, and the expression px1 == px2 evaluates to true.
Let w1 and w2 denote objects of type X::void_pointer. Then for the expressions
w1 == w2 w1 != w2
either or both objects may be replaced by an equivalently-valued object of type X::const_void_pointer with no change in semantics.
Let p1 and p2 denote objects of type X::pointer. Then for the expressions
p1 == p2 p1 != p2 p1 < p2 p1 <= p2 p1 >= p2 p1 > p2 p1 - p2
either or both objects may be replaced by an equivalently-valued object of type X::const_pointer with no change in semantics.
An allocator may constrain the types on which it can be instantiated and the arguments for which its construct or destroy members may be called. If a type cannot be used with a particular allocator, the allocator class or the call to construct or destroy may fail to instantiate.
[ Example: The following is an allocator class template supporting the minimal interface that satisfies the requirements of Table 31:
template <class Tp> struct SimpleAllocator { typedef Tp value_type; SimpleAllocator(ctor args); template <class T> SimpleAllocator(const SimpleAllocator<T>& other); Tp* allocate(std::size_t n); void deallocate(Tp* p, std::size_t n); }; template <class T, class U> bool operator==(const SimpleAllocator<T>&, const SimpleAllocator<U>&); template <class T, class U> bool operator!=(const SimpleAllocator<T>&, const SimpleAllocator<U>&);
— end example ]
If the alignment associated with a specific over-aligned type is not supported by an allocator, instantiation of the allocator for that type may fail. The allocator also may silently ignore the requested alignment. [ Note: Additionally, the member function allocate for that type may fail by throwing an object of type bad_alloc. — end note ]
20.5.3.5.1 Allocator completeness requirements [allocator.requirements.completeness]If X is an allocator class for type T, X additionally satisfies the allocator completeness requirements if, whether or not T is a complete type:
X is a complete type, and
all the member types of allocator_traits<X> other than value_type are complete types.
The behavior of a C++ program is undefined if it adds declarations or definitions to namespace std or to a namespace within namespace std unless otherwise specified. A program may add a template specialization for any standard library template to namespace std only if the declaration depends on a user-defined type and the specialization meets the standard library requirements for the original template and is not explicitly prohibited.176
The behavior of a C++ program is undefined if it declares
an explicit specialization of any member function of a standard library class template, or
an explicit specialization of any member function template of a standard library class or class template, or
an explicit or partial specialization of any member class template of a standard library class or class template, or
a deduction guide for any standard library class template.
A program may explicitly instantiate a template defined in the standard library only if the declaration depends on the name of a user-defined type and the instantiation meets the standard library requirements for the original template.
A translation unit shall not declare namespace std to be an inline namespace ([namespace.def]).
20.5.4.2.2 Namespace posix [namespace.posix]The behavior of a C++ program is undefined if it adds declarations or definitions to namespace posix or to a namespace within namespace posix unless otherwise specified. The namespace posix is reserved for use by ISO/IEC 9945 and other POSIX standards.
20.5.4.2.3 Namespaces for future standardization [namespace.future]Top level namespaces with a name starting with std and followed by a non-empty sequence of digits are reserved for future standardization. The behavior of a C++ program is undefined if it adds declarations or definitions to such a namespace. [ Example: The top level namespace std2 is reserved for use by future revisions of this International Standard. — end example ]
20.5.4.3 Reserved names [reserved.names]The C++ standard library reserves the following kinds of names:
macros
global names
names with external linkage
If a program declares or defines a name in a context where it is reserved, other than as explicitly allowed by this Clause, its behavior is undefined.
20.5.4.3.1 Zombie names [zombie.names]In namespace std, the following names are reserved for previous standardization:
A translation unit that includes a standard library header shall not #define or #undef names declared in any standard library header.
A translation unit shall not #define or #undef names lexically identical to keywords, to the identifiers listed in Table 4, or to the attribute-tokens described in [dcl.attr].
20.5.4.3.3 External linkage [extern.names]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,177 both in namespace std and in the global namespace.
Each global function signature declared with external linkage in a header is reserved to the implementation to designate that function signature with external linkage.178
Each name from the C standard 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.
Each function signature from the C standard library declared with external linkage is reserved to the implementation for use as a function signature with both extern "C" and extern "C++" linkage,179 or as a name of namespace scope in the global namespace.
20.5.4.3.4 Types [extern.types]For each type T from the C standard library,180 the types ::T and std::T are reserved to the implementation and, when defined, ::T shall be identical to std::T.
20.5.4.5 Derived classes [derived.classes]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 ([class.virtual]).
20.5.4.6 Replacement functions [replacement.functions]Clauses [language.support] through [thread] and Annex [depr] 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 ([definitions]).
A C++ program may provide the definition for any of the following dynamic memory allocation function signatures declared in header <new> ([basic.stc.dynamic], [support.dynamic]):
operator new(std::size_t) operator new(std::size_t, std::align_val_t) operator new(std::size_t, const std::nothrow_t&) operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
operator delete(void*) operator delete(void*, std::size_t) operator delete(void*, std::align_val_t) operator delete(void*, std::size_t, std::align_val_t) operator delete(void*, const std::nothrow_t&) operator delete(void*, std::align_val_t, const std::nothrow_t&)
operator new[](std::size_t) operator new[](std::size_t, std::align_val_t) operator new[](std::size_t, const std::nothrow_t&) operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
operator delete[](void*) operator delete[](void*, std::size_t) operator delete[](void*, std::align_val_t) operator delete[](void*, std::size_t, std::align_val_t) operator delete[](void*, const std::nothrow_t&) operator delete[](void*, std::align_val_t, const std::nothrow_t&)
The program's definitions are used instead of the default versions supplied by the implementation ([support.dynamic]). Such replacement occurs prior to program startup ([basic.def.odr], [basic.start]). The program's declarations shall not be specified as inline. No diagnostic is required.
20.5.4.7 Handler functions [handler.functions]The C++ standard library provides a default version of the following handler function (Clause [language.support]):
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 [alloc.errors], Storage allocation errors, and [support.exception], Exception handling.
A C++ program can get a pointer to the current handler function by calling the following functions:
Calling the set_* and get_* functions shall not incur a data race. A call to any of the set_* functions shall synchronize with subsequent calls to the same set_* function and to the corresponding get_* function.
20.5.4.8 Other functions [res.on.functions]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, this International Standard places no requirements on the implementation.
In particular, the effects are undefined in the following cases:
for replacement functions, if the installed replacement function does not implement the semantics of the applicable Required behavior: paragraph.
for handler functions ([new.handler], [terminate.handler]), if the installed handler function does not implement the semantics of the applicable Required behavior: paragraph
for types used as template arguments when instantiating a template component, if the operations on the type do not implement the semantics of the applicable Requirements subclause ([allocator.requirements], [container.requirements], [iterator.requirements], [algorithms.requirements], [numeric.requirements]). Operations on such types can report a failure by throwing an exception unless otherwise specified.
if any replacement function or handler function or destructor operation exits via an exception, unless specifically allowed in the applicable Required behavior: paragraph.
if an incomplete type is used as a template argument when instantiating a template component, unless specifically allowed for that component.
Each of the following applies to all arguments to functions defined in the C++ standard library, unless explicitly stated otherwise.
If an argument to a function has an invalid value (such as a value outside the domain of the function or a pointer invalid for its intended use), the behavior is undefined.
If a function argument is described as being an array, the pointer actually passed to the function shall have a value such that all address computations and accesses to objects (that would be valid if the pointer did point to the first element of such an array) are in fact valid.
If a function argument binds to an rvalue reference parameter, the implementation may assume that this parameter is a unique reference to this argument. [ Note: If the parameter is a generic parameter of the form T&& and an lvalue of type A is bound, the argument binds to an lvalue reference ([temp.deduct.call]) and thus is not covered by the previous sentence. — end note ] [ Note: If a program casts an lvalue to an xvalue while passing that lvalue to a library function (e.g. by calling the function with the argument std::move(x)), the program is effectively asking that function to treat that lvalue as a temporary. The implementation is free to optimize away aliasing checks which might be needed if the argument was an lvalue. — end note ]
The behavior of a program is undefined if calls to standard library functions from different threads may introduce a data race. The conditions under which this may occur are specified in [res.on.data.races]. [ Note: Modifying an object of a standard library type that is shared between threads risks undefined behavior unless objects of that type are explicitly specified as being sharable without data races or the user supplies a locking mechanism. — end note ]
If an object of a standard library type is accessed, and the beginning of the object's lifetime does not happen before the access, or the access does not happen before the end of the object's lifetime, the behavior is undefined unless otherwise specified. [ Note: This applies even to objects such as mutexes intended for thread synchronization. — end note ]
20.5.4.11 Requires paragraph [res.on.required]Violation of the preconditions specified in a function's Requires: paragraph results in undefined behavior unless the function's Throws: paragraph specifies throwing an exception when the precondition is violated.
20.5.5 Conforming implementations [conforming] 20.5.5.1 Overview [conforming.overview]This section describes the constraints upon, and latitude of, implementations of the C++ standard library.
20.5.5.3 Restrictions on macro definitions [res.on.macro.definitions]The names and global function signatures described in [contents] are reserved to the implementation.
All object-like macros defined by the C standard 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.
20.5.5.4 Non-member functions [global.functions]It is unspecified whether any non-member functions in the C++ standard library are defined as inline.
A call to a non-member function signature described in Clauses [language.support] through [thread] and Annex [depr] shall behave as if the implementation declared no additional non-member function signatures.181
An implementation shall not declare a non-member function signature with additional default arguments.
Unless otherwise specified, calls made by functions in the standard library to non-operator, non-member functions do not use functions from another namespace which are found through argument-dependent name lookup ([basic.lookup.argdep]). [ Note: The phrase “unless otherwise specified” applies to cases such as the swappable with requirements ([swappable.requirements]). The exception for overloaded operators allows argument-dependent lookup in cases like that of ostream_iterator::operator=:
Effects:
*out_stream << value; if (delim != 0) *out_stream << delim; return *this;
— end note ]
20.5.5.5 Member functions [member.functions]It is unspecified whether any member functions in the C++ standard library are defined as inline.
For a non-virtual member function described in the C++ standard library, an implementation may declare a different set of member function signatures, provided that any call to the member function that would select an overload from the set of declarations described in this International Standard behaves as if that overload were selected. [ Note: For instance, an implementation may add parameters with default values, or replace a member function with default arguments with two or more member functions with equivalent behavior, or add additional signatures for a member function name. — end note ]
20.5.5.6 Constexpr functions and constructors [constexpr.functions]This International Standard explicitly requires that certain standard library functions are constexpr. An implementation shall not declare any standard library function signature as constexpr except for those where it is explicitly required. Within any header that provides any non-defining declarations of constexpr functions or constructors an implementation shall provide corresponding definitions.
20.5.5.7 Requirements for stable algorithms [algorithm.stable]When the requirements for an algorithm state that it is “stable” without further elaboration, it means:
For the sort algorithms the relative order of equivalent elements is preserved.
For the remove and copy algorithms the relative order of the elements that are not removed is preserved.
For the merge algorithms, for equivalent elements in the original two ranges, the elements from the first range (preserving their original order) precede the elements from the second range (preserving their original order).
Except where explicitly specified in this International Standard, it is implementation-defined which functions in the C++ standard library may be recursively reentered.
20.5.5.9 Data race avoidance [res.on.data.races]This section specifies requirements that implementations shall meet to prevent data races. Every standard library function shall meet each requirement unless otherwise specified. Implementations may prevent data races in cases other than those specified below.
A C++ standard library function shall not directly or indirectly access objects ([intro.multithread]) accessible by threads other than the current thread unless the objects are accessed directly or indirectly via the function's arguments, including this.
A C++ standard library function shall not directly or indirectly modify objects ([intro.multithread]) accessible by threads other than the current thread unless the objects are accessed directly or indirectly via the function's non-const arguments, including this.
[ Note: This means, for example, that implementations can't use a static object for internal purposes without synchronization because it could cause a data race even in programs that do not explicitly share objects between threads. — end note ]
A C++ standard library function shall not access objects indirectly accessible via its arguments or via elements of its container arguments except by invoking functions required by its specification on those container elements.
Operations on iterators obtained by calling a standard library container or string member function may access the underlying container, but shall not modify it. [ Note: In particular, container operations that invalidate iterators conflict with operations on iterators associated with that container. — end note ]
Implementations may share their own internal objects between threads if the objects are not visible to users and are protected against data races.
Unless otherwise specified, C++ standard library functions shall perform all operations solely within the current thread if those operations have effects that are visible to users.
[ Note: This allows implementations to parallelize operations if there are no visible side effects. — end note ]
20.5.5.11 Derived classes [derivation]An implementation may derive any class in the C++ standard library from a class with a name reserved to the implementation.
Certain classes defined in the C++ standard library are required to be derived from other classes in the C++ standard library. An implementation may derive such a class directly from the required base or indirectly through a hierarchy of base classes with names reserved to the implementation.
In any case:
Every base class not specified as virtual shall not be virtual;
Unless explicitly stated otherwise, types with distinct names shall be distinct types.182
All types specified in the C++ standard library shall be non-final types unless otherwise specified.
20.5.5.12 Restrictions on exception handling [res.on.exception.handling]Any of the functions defined in the C++ standard library can report a failure by throwing an exception of a type described in its Throws: paragraph, or of a type derived from a type named in the Throws: paragraph that would be caught by an exception handler for the base type.
Functions from the C standard library shall not throw exceptions183 except when such a function calls a program-supplied function that throws an exception.184
Destructor operations defined in the C++ standard library shall not throw exceptions. Every destructor in the C++ standard library shall behave as if it had a non-throwing exception specification.
Functions defined in the C++ standard library that do not have a Throws: paragraph but do have a potentially-throwing exception specification may throw implementation-defined exceptions.185 Implementations should report errors by throwing exceptions of or derived from the standard exception classes ([bad.alloc], [support.exception], [std.exceptions]).
An implementation may strengthen the exception specification for a non-virtual function by adding a non-throwing exception specification.
20.5.5.13 Restrictions on storage of pointers [res.on.pointer.storage]Objects constructed by the standard library that may hold a user-supplied pointer value or an integer of type std::intptr_t shall store such values in a traceable pointer location. [ Note: Other libraries are strongly encouraged to do the same, since not doing so may result in accidental use of pointers that are not safely derived. Libraries that store pointers outside the user's address space should make it appear that they are stored and retrieved from a traceable pointer location. — end note ]
20.5.5.14 Value of error codes [value.error.codes]Certain functions in the C++ standard library report errors via a std::error_code object. That object's category() member shall return std::system_category() for errors originating from the operating system, or a reference to an implementation-defined error_category object for errors originating elsewhere. The implementation shall define the possible values of value() for each of these error categories. [ Example: For operating systems that are based on POSIX, implementations are encouraged to define the std::system_category() values as identical to the POSIX errno values, with additional values as defined by the operating system's documentation. Implementations for operating systems that are not based on POSIX are encouraged to define values identical to the operating system's values. For errors that do not originate from the operating system, the implementation may provide enums for the associated values. — end example ]
20.5.5.15 Moved-from state of library types [lib.types.movedfrom]Objects of types defined in the C++ standard library may be moved from ([class.copy]). Move operations may be explicitly specified or implicitly generated. Unless otherwise specified, such moved-from objects shall be placed in a valid but unspecified state.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4