A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://timsong-cpp.github.io/cppwp/n4140/requirements below:

[requirements]

17.6 Library-wide requirements [requirements]

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.

17.6.1 Library contents and organization [organization]

[contents] describes the entities 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.

17.6.1.1 Library contents [contents]

The C++ standard library provides definitions for the following types of entities: macros, values, types, templates, classes, functions, objects.

All library entities except macros, operator new and operator delete are defined within the namespace std or namespaces nested within namespace std.173 It is unspecified whether names declared in a specific namespace are declared directly in that namespace or in an inline namespace inside that namespace.174

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.

17.6.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 [tab:cpp.headers.freestanding].

Table

16

— 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.

17.6.2 Using the library [using] 17.6.2.3 Linkage [using.linkage]

Entities in the C++ standard library have external linkage ([basic.link]). 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.180

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 ([replacement.functions]), run-time changes ([handler.functions]).

17.6.3 Requirements on types and expressions [utility.requirements] 17.6.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 [equalitycomparable][destructible]. 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 ([dcl.fct.default]).

Table

17

EqualityComparable

requirements


Expression Return type Requirement a == b convertible to bool == is an equivalence relation, that is, it has the following properties:

Table

18

LessThanComparable

requirements


Expression Return type Requirement a < b convertible to bool < is a strict weak ordering relation ([alg.sorting])

Table

19

DefaultConstructible

requirements


Expression Post-condition T t; object t is default-initialized T u{}; object u is value-initialized T() a temporary object of type T is value-initialized T{}

Table

20

MoveConstructible

requirements


Expression Post-condition T u = rv; u is equivalent to the value of rv before the construction T(rv) T(rv) is equivalent to the value of rv before the construction rv's state is unspecified [ Note: rv must still meet the requirements of the library component that is using it. The operations listed in those requirements must work as specified whether rv has been moved from or not.  — end note ]

Table

21

CopyConstructible

requirements (in addition to

MoveConstructible

)


Expression Post-condition T u = v; the value of v is unchanged and is equivalent to u T(v) the value of v is unchanged and is equivalent to T(v)

Table

22

MoveAssignable

requirements


Expression Return type Return value Post-condition t = rv T& t t is equivalent to the value of rv before the assignment rv's state is unspecified. [ Note: rv must still meet the requirements of the library component that is using it. The operations listed in those requirements must work as specified whether rv has been moved from or not.  — end note ]

Table

23

CopyAssignable

requirements (in addition to

MoveAssignable

)


Expression Return type Return value Post-condition t = v T& t t is equivalent to v, the value of v is unchanged

Table

24

Destructible

requirements


Expression Post-condition u.~T() All resources owned by u are reclaimed, no exception is propagated. 17.6.3.2 Swappable requirements [swappable.requirements]

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 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 ([over.match]) on a candidate set that includes:

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 ([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 ]

17.6.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:

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 ]

An object p of type P can be contextually converted to bool (Clause [conv]). The effect shall be as if p != nullptr had been evaluated in place of p.

No operation which is part of the NullablePointer requirements shall exit via an exception.

In Table [nullablepointer], 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

25

NullablePointer

requirements


Expression Return type Operational semantics P u(np);
post: u == nullptr P u = np; P(np) post: P(np) == nullptr t = np P& post: t == nullptr a != b contextually convertible to bool !(a == b) a == np contextually convertible to bool a == P() np == a a != np contextually convertible to bool !(a == np) np != a 17.6.3.4 Hash requirements [hash.requirements]

A type H meets the Hash requirements if:

Given Key is an argument type for function objects of type H, in Table [hash] 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

26

Hash

requirements


Expression Return type Requirement h(k) size_t The value returned shall depend only on the argument k for the duration of the program. [ Note: Thus all evaluations of the expression h(k) with the same value for k yield the same result for a given execution of the program.  — end note ] [ Note: For two different values t1 and t2, the probability that h(t1) and h(t2) compare equal should be very small, approaching 1.0 / numeric_limits<size_t>::max().  — end note ] h(u) size_t Shall not modify u. 17.6.3.5 Allocator requirements [allocator.requirements]

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 (Clause [strings]), containers (Clause [containers]) (except array), string buffers and string streams (Clause [input.output]), and match_results (Clause [re]) are parameterized in terms of allocators.

The template struct allocator_traits ([allocator.traits]) supplies a uniform interface to all allocator types. Table [tab:desc.var.def] describes the types manipulated through allocators. Table [tab:utilities.allocator.requirements] 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 [tab:utilities.allocator.requirements] 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 [tab:desc.var.def] and [tab:utilities.allocator.requirements], the use of move and forward always refers to std::move and std::forward, respectively.

Table

27

— Descriptive variable definitions


Variable Definition T, U, C any non-const object type ([basic.types]) V a type convertible to T X an Allocator class for type T Y the corresponding Allocator class for type U XX the type allocator_traits<X> YY the type allocator_traits<Y> t a value of type const T& a, a1, a2 values of type X& a3 an rvalue of type X b a value of type Y c a pointer of type C* through which indirection is valid p a value of type XX::pointer, obtained by calling a1.allocate, where a1 == a q a value of type XX::const_pointer obtained by conversion from a value p. w a value of type XX::void_pointer obtained by conversion from a value p z a value of type XX::const_void_pointer obtained by conversion from a value q or a value w r a value of type T& obtained by the expression *p. s a value of type const T& obtained by the expression *q or by conversion from a value r. u a value of type XX:const_void_pointer obtained by conversion from a result value of YY::allocate, or else a value of type (possibly const) std::nullptr_t. v a value of type V n a value of type XX::size_type. Args a template parameter pack args a function parameter pack with the pattern Args&&

Table

28

— Allocator requirements


Expression Return type Assertion/note Default pre-/post-condition X::pointer T* X::const_pointer X::pointer is convertible to X::const_pointer pointer_traits<X::pointer>::rebind<const T> X::void_pointer
Y::void_pointer X::pointer is convertible to X::void_pointer. X::void_pointer and Y::void_pointer are the same type. pointer_traits<X::pointer>::rebind<void> X::const_void_pointer
Y::const_void_pointer X::pointer, X::const_pointer, and X::void_pointer are convertible to X::const_void_pointer. X::const_void_pointer and Y::const_void_pointer are the same type. pointer_traits<X::pointer>::rebind<const void> X::value_type Identical to T X::size_type unsigned integer type a type that can represent the size of the largest object in the allocation model. make_unsigned_t<X::difference_type> X::difference_type signed integer type a type that can represent the difference between any two pointers in the allocation model. pointer_traits<X::pointer>::difference_type typename X::template rebind<U>::other Y For all U (including T), Y::template rebind<T>::other is X. See Note A, below. *p T& *q const T& *q refers to the same object as *p p->m type of T::m pre: (*p).m is well-defined. equivalent to (*p).m q->m type of T::m pre: (*q).m is well-defined. equivalent to (*q).m static_- cast<X::pointer>(w) X::pointer static_cast<X::pointer>(w) == p static_cast<X ::const_pointer>(z) X::const_pointer static_cast<X ::const_pointer>(z) == q a.allocate(n) X::pointer Memory is allocated for n objects of type T but objects are not constructed. allocate may raise an appropriate exception.181Note: If n == 0, the return value is unspecified.  — end note ] a.allocate(n, u) X::pointer Same as a.allocate(n). The use of u is unspecified, but it is intended as an aid to locality. a.allocate(n) a.deallocate(p,n) (not used) All n T objects in the area pointed to by p shall be destroyed prior to this call. n shall match the value passed to allocate to obtain this memory. Does not throw exceptions. [ Note: p shall not be singular. — end note ] a.max_size() X::size_type the largest value that can meaningfully be passed to X::allocate() numeric_limits<size_type>::max() a1 == a2 bool returns true only if storage allocated from each can be deallocated via the other. operator== shall be reflexive, symmetric, and transitive, and shall not exit via an exception. a1 != a2 bool same as !(a1 == a2) a == b bool same as a == Y::rebind<T>::other(b) a != b bool same as !(a == b) X a1(a);
X a1 = a; Shall not exit via an exception.
post: a1 == a X a(b); Shall not exit via an exception.
post: Y(a) == b, a == X(b) X a1(move(a));
X a1 = move(a); Shall not exit via an exception.
post: a1 equals the prior value of a. X a(move(b)); Shall not exit via an exception.
post: a equals the prior value of X(b). a.construct(c, args) (not used) Effect: Constructs an object of type C at c ::new ((void*)c) C(forward<Args>(args)...) a.destroy(c) (not used) Effect: Destroys the object at c c->~C() a.select_on_container_copy_construction() X Typically returns either a or X() return a; X::propagate_on_container_copy_assignment Identical to or derived from true_type or false_type true_type only if an allocator of type X should be copied when the client container is copy-assigned. false_type X::propagate_on_container_move_assignment Identical to or derived from true_type or false_type true_type only if an allocator of type X should be moved when the client container is move-assigned. false_type X::propagate_on_- container_swap Identical to or derived from true_type or false_type true_type only if an allocator of type X should be swapped when the client container is swapped. false_type

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.

An allocator type X shall satisfy the requirements of CopyConstructible ([utility.arg.requirements]). The X::pointer, X::const_pointer, X::void_pointer, and X::const_void_pointer types shall satisfy the requirements of NullablePointer ([nullablepointer.requirements]). No constructor, comparison operator, copy operation, move operation, or swap operation on these types shall exit via an exception. X::pointer and X::const_pointer shall also satisfy the requirements for a random access iterator ([iterator.requirements]).

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 member may be called. If a type cannot be used with a particular allocator, the allocator class or the call to construct may fail to instantiate.

Example: the following is an allocator class template supporting the minimal interface that satisfies the requirements of Table [tab:utilities.allocator.requirements]:

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 std::bad_alloc. — end note ]

17.6.4 Constraints on programs [constraints] 17.6.4.2 Namespace use [namespace.constraints] 17.6.4.2.1 Namespace std [namespace.std]

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.182

The behavior of a C++ program is undefined if it declares

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]).

17.6.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.

17.6.4.3 Reserved names [reserved.names]

The C++ standard library reserves the following kinds of names:

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.

17.6.4.3.1 Macro names [macro.names]

A translation unit that includes a standard library header shall not #define or #undef names declared in any standard library header.

17.6.4.3.2 Global names [global.names]

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

17.6.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,183 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. 184

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.

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, 185 or as a name of namespace scope in the global namespace.

17.6.4.3.4 Types [extern.types]

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

17.6.4.3.5 User-defined literal suffixes [usrlit.suffix]

Literal suffix identifiers that do not start with an underscore are reserved for future standardization.

17.6.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]).

17.6.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 twelve dynamic memory allocation function signatures declared in header <new> ([basic.stc.dynamic], [support.dynamic]):

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 definitions shall not be specified as inline. No diagnostic is required.

17.6.4.7 Handler functions [handler.functions]

The C++ standard library provides default versions of the following handler functions (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):

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.

17.6.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, the Standard places no requirements on the implementation.

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

17.6.4.9 Function arguments [res.on.arguments]

Each of the following applies to all arguments to functions defined in the C++ standard library, unless explicitly stated otherwise.

17.6.4.10 Shared objects and the library [res.on.objects]

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 ]

Note: In particular, the program is required to ensure that completion of the constructor of any object of a class type defined in the standard library happens before any other member function invocation on that object and, unless otherwise specified, to ensure that completion of any member function invocation other than destruction on such an object happens before destruction of that object. This applies even to objects such as mutexes intended for thread synchronization.  — end note ]

17.6.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.

17.6.5 Conforming implementations [conforming] 17.6.5.1 Overview [conforming.overview]

This section describes the constraints upon, and latitude of, implementations of the C++ standard library.

17.6.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.

17.6.5.4 Global and non-member functions [global.functions]

It is unspecified whether any global or non-member functions in the C++ standard library are defined as inline ([dcl.fct.spec]).

A call to a global or non-member function signature described in Clauses [language.support] through [thread] and Annex [depr] shall behave as if the implementation declared no additional global or non-member function signatures.187

An implementation shall not declare a global or non-member function signature with additional default arguments.

Unless otherwise specified, global and non-member functions in the standard library shall not use functions from another namespace which are found through argument-dependent name lookup ([basic.lookup.argdep]). [ Note: The phrase “unless otherwise specified” is intended to allow argument-dependent lookup in cases like that of ostream_iterator::operator= ([ostream.iterator.ops]):

Effects:

*out_stream << value;
if (delim != 0)
  *out_stream << delim;
return *this;

 — end note ]

17.6.5.5 Member functions [member.functions]

It is unspecified whether any member functions in the C++ standard library are defined as inline ([dcl.fct.spec]).

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

A call to a member function signature described in the C++ standard library behaves as if the implementation declares no additional member function signatures.189

17.6.5.6 constexpr functions and constructors [constexpr.functions]

This standard explicitly requires that certain standard library functions are constexpr ([dcl.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.

17.6.5.7 Requirements for stable algorithms [algorithm.stable]

When the requirements for an algorithm state that it is “stable” without further elaboration, it means:

17.6.5.8 Reentrancy [reentrancy]

Except where explicitly specified in this standard, it is implementation-defined which functions in the Standard C++ library may be recursively reentered.

17.6.5.9 Data race avoidance [res.on.data.races]

This section specifies requirements that implementations shall meet to prevent data races ([intro.multithread]). 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 ([intro.multithread]) to users.

Note: This allows implementations to parallelize operations if there are no visible side effects.  — end note ]

17.6.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:

17.6.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. An implementation may strengthen the exception-specification for a non-virtual function by adding a non-throwing noexcept-specification.

A function may throw an object of a type not listed in its Throws clause if its type is derived from a type named in the Throws clause and would be caught by an exception handler for the base type.

Functions from the C standard library shall not throw exceptions191 except when such a function calls a program-supplied function that throws an exception.192

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. Any other functions defined in the C++ standard library that do not have an exception-specification may throw implementation-defined exceptions unless otherwise specified.193 An implementation may strengthen this implicit exception-specification by adding an explicit one.194

17.6.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 ([basic.stc.dynamic.safety]). [ 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 ]

17.6.5.14 Value of error codes [value.error.codes]

Certain functions in the C++ standard library report errors via a std::error_code ([syserr.errcode.overview]) 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 ]

17.6.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