This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
[res.contract.assertions]
# 16 Library introduction [[library]](./#library)
## 16.4 Library-wide requirements [[requirements]](requirements#res.contract.assertions)
### 16.4.6 Conforming implementations [[conforming]](conforming#res.contract.assertions)
#### 16.4.6.15 Contract assertions [res.contract.assertions]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3960)
Unless specified otherwise,
an implementation may check
the specified preconditions and postconditions of a function
in the C++ standard library using contract
assertions ([[basic.contract]](basic.contract "6.11Contract assertions"), [[structure.specifications]](structure.specifications "16.3.2.4Detailed specifications"))[.](#1.sentence-1)

View File

@@ -0,0 +1,47 @@
[res.on.arguments]
# 16 Library introduction [[library]](./#library)
## 16.4 Library-wide requirements [[requirements]](requirements#res.on.arguments)
### 16.4.5 Constraints on programs [[constraints]](constraints#res.on.arguments)
#### 16.4.5.9 Function arguments [res.on.arguments]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3496)
Each of the following applies to all argumentsto functions defined in the C++ standard library, unless explicitly stated otherwise[.](#1.sentence-1)
- [(1.1)](#1.1)
If an argument to a function has an invalid value (suchas a value outside the domain of the function or a pointer invalid for its
intended use), the behavior is undefined[.](#1.1.sentence-1)
- [(1.2)](#1.2)
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[.](#1.2.sentence-1)
- [(1.3)](#1.3)
If a function argument is bound to an rvalue reference parameter, the implementation may
assume that this parameter is a unique reference to this argument,
except that the argument passed to a move assignment operator may be
a reference to *this ([[lib.types.movedfrom]](lib.types.movedfrom "16.4.6.17Moved-from state of library types"))[.](#1.3.sentence-1)
[*Note [1](#note-1)*:
If the type of a parameter is a forwarding reference ([[temp.deduct.call]](temp.deduct.call "13.10.3.2Deducing template arguments from a function call"))
that is deduced to an lvalue reference type, then
the argument is not bound to an rvalue reference[.](#1.3.sentence-2)
— *end note*]
[*Note [2](#note-2)*:
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 object[.](#1.3.sentence-3)
The implementation
is free to optimize away aliasing checks which would possibly be needed if the argument was
an lvalue[.](#1.3.sentence-4)
— *end note*]

View File

@@ -0,0 +1,95 @@
[res.on.data.races]
# 16 Library introduction [[library]](./#library)
## 16.4 Library-wide requirements [[requirements]](requirements#res.on.data.races)
### 16.4.6 Conforming implementations [[conforming]](conforming#res.on.data.races)
#### 16.4.6.10 Data race avoidance [res.on.data.races]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3769)
This subclause specifies requirements that implementations shall meet to prevent[data races](intro.multithread#def:data_race "6.10.2Multi-threaded executions and data races[intro.multithread]")[.](#1.sentence-1)
Every standard library function shall meet each requirement unless otherwise specified[.](#1.sentence-2)
Implementations may prevent data races in cases other than those specified below[.](#1.sentence-3)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3775)
A C++ standard library function shall not directly or indirectly access
objects ([[intro.multithread]](intro.multithread "6.10.2Multi-threaded executions and data races")) accessible by threads other than the current thread
unless the objects are accessed directly or indirectly via the function's arguments,
including this[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3781)
A C++ standard library function shall not directly or indirectly modify
objects ([[intro.multithread]](intro.multithread "6.10.2Multi-threaded executions and data races")) 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[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3787)
[*Note [1](#note-1)*:
This means, for example, that implementations can't use an object with static storage duration for
internal purposes without synchronization because doing so can cause a data race even in
programs that do not explicitly share objects between threads[.](#4.sentence-1)
— *end note*]
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3794)
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[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3799)
Operations on iterators obtained by calling a standard library container or string
member function may access the underlying container, but shall not modify it[.](#6.sentence-1)
[*Note [2](#note-2)*:
In particular, container operations that invalidate iterators conflict
with operations on iterators associated with that container[.](#6.sentence-2)
— *end note*]
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3807)
Implementations may share their own internal objects between threads if the objects are
not visible to users and are protected against data races[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3811)
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#def:side_effects,visible "6.10.2Multi-threaded executions and data races[intro.multithread]") to users[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3816)
[*Note [3](#note-3)*:
This allows implementations to parallelize operations if there are no visibleside effects[.](#9.sentence-1)
— *end note*]

View File

@@ -0,0 +1,76 @@
[res.on.exception.handling]
# 16 Library introduction [[library]](./#library)
## 16.4 Library-wide requirements [[requirements]](requirements#res.on.exception.handling)
### 16.4.6 Conforming implementations [[conforming]](conforming#res.on.exception.handling)
#### 16.4.6.14 Restrictions on exception handling [res.on.exception.handling]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3900)
Any of the functions defined in the C++ standard librarycan 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 a [*handler*](except.pre#nt:handler "14.1Preamble[except.pre]") ([[except.handle]](except.handle "14.4Handling an exception")) for the base type[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3908)
Functions from the C standard library shall not throw exceptions[156](#footnote-156 "That is, the C standard library functions can all be treated as if they are marked noexcept. This allows implementations to make performance optimizations based on the absence of exceptions at runtime.") except when such a function calls a program-supplied function that throws an
exception[.](#2.sentence-1)[157](#footnote-157 "The functions qsort() and bsearch() ([alg.c.library]) meet this condition.")
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3926)
Destructor operations defined in the C++ standard library
shall not throw exceptions[.](#3.sentence-1)
Every destructor in the C++ standard library shall behave as if it had a
non-throwing exception specification ([[except.spec]](except.spec "14.5Exception specifications"))[.](#3.sentence-2)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3932)
Functions defined in the
C++ standard librarythat do not have a *Throws*: paragraph
but do have a potentially-throwing exception specification
may throw implementation-defined exceptions[.](#4.sentence-1)[158](#footnote-158 "In particular, they can report a failure to allocate storage by throwing an exception of type bad_­alloc, or a class derived from bad_­alloc ([bad.alloc]).")
Implementations should
report errors by throwing exceptions of or derived
from the standard
exception classes ([[bad.alloc]](bad.alloc "17.6.4.1Class bad_­alloc"), [[support.exception]](support.exception "17.9Exception handling"), [[std.exceptions]](std.exceptions "19.2Exception classes"))[.](#4.sentence-2)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3952)
An implementation may strengthen the
exception specification
for a non-virtual function
by adding a non-throwing exception specification[.](#5.sentence-1)
[156)](#footnote-156)[156)](#footnoteref-156)
That is, the C standard library functions can all be treated as if they
are marked noexcept[.](#footnote-156.sentence-1)
This allows implementations to make performance optimizations
based on the absence of exceptions at runtime[.](#footnote-156.sentence-2)
[157)](#footnote-157)[157)](#footnoteref-157)
The functionsqsort() andbsearch() ([[alg.c.library]](alg.c.library "26.13C library algorithms")) meet this condition[.](#footnote-157.sentence-1)
[158)](#footnote-158)[158)](#footnoteref-158)
In particular, they
can report a failure to allocate storage by throwing an exception of type[bad_alloc](bad.alloc "17.6.4.1Class bad_­alloc[bad.alloc]"),
or a class derived frombad_alloc ([[bad.alloc]](bad.alloc "17.6.4.1Class bad_­alloc"))[.](#footnote-158.sentence-1)

View File

@@ -0,0 +1,55 @@
[res.on.functions]
# 16 Library introduction [[library]](./#library)
## 16.4 Library-wide requirements [[requirements]](requirements#res.on.functions)
### 16.4.5 Constraints on programs [[constraints]](constraints#res.on.functions)
#### 16.4.5.8 Other functions [res.on.functions]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3454)
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[.](#1.sentence-1)
If these components do not meet their requirements, this document places no requirements
on the implementation[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3461)
In particular, the behavior is undefined in the following cases:
- [(2.1)](#2.1)
For replacement functions ([[replacement.functions]](replacement.functions "16.4.5.6Replacement functions")), if the installed replacement function does not
implement the semantics of the applicable*Required behavior*: paragraph[.](#2.1.sentence-1)
- [(2.2)](#2.2)
For handler functions ([[new.handler]](new.handler "17.6.4.3Type new_­handler"), [[terminate.handler]](terminate.handler "17.9.5.1Type terminate_­handler")),
if the installed handler function does not implement the semantics of the applicable*Required behavior*: paragraph[.](#2.2.sentence-1)
- [(2.3)](#2.3)
For types used as template arguments when instantiating a template component,
if the operations on the type do not implement the semantics of the applicableRequirements subclause ([[allocator.requirements]](allocator.requirements "16.4.4.6Cpp17Allocator requirements"), [[container.requirements]](container.requirements "23.2Requirements"), [[iterator.requirements]](iterator.requirements "24.3Iterator requirements"), [[algorithms.requirements]](algorithms.requirements "26.2Algorithms requirements"), [[numeric.requirements]](numeric.requirements "29.2Numeric type requirements"))[.](#2.3.sentence-1)
Operations on such types can report a failure by throwing an exception
unless otherwise specified[.](#2.3.sentence-2)
- [(2.4)](#2.4)
If any replacement function or handler function or destructor operation exits via an exception,
unless specifically allowed
in the applicable*Required behavior*: paragraph[.](#2.4.sentence-1)
- [(2.5)](#2.5)
If an incomplete type ([[basic.types.general]](basic.types.general#term.incomplete.type "6.9.1General")) is used as a template
argument when instantiating a template component or evaluating a concept, unless specifically
allowed for that component[.](#2.5.sentence-1)

View File

@@ -0,0 +1,38 @@
[res.on.headers]
# 16 Library introduction [[library]](./#library)
## 16.4 Library-wide requirements [[requirements]](requirements#res.on.headers)
### 16.4.6 Conforming implementations [[conforming]](conforming#res.on.headers)
#### 16.4.6.2 Headers [res.on.headers]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3608)
A C++ header may include other C++ headers[.](#1.sentence-1)
A C++ header shall provide the declarations and definitions that appear in its
synopsis[.](#1.sentence-2)
A C++ header shown in its synopsis as including other C++ headers
shall provide the declarations and definitions that appear in the synopses of
those other headers[.](#1.sentence-3)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3615)
Certain types and macros are defined in more than one header[.](#2.sentence-1)
Every such entity shall be defined such that any header that defines it may be
included after any other header that also defines it ([[basic.def.odr]](basic.def.odr "6.3One-definition rule"))[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3620)
The [C standard library headers](support.c.headers "17.15C headers[support.c.headers]") shall include only their corresponding C++ standard library header,
as described in [[headers]](headers "16.4.2.3Headers")[.](#3.sentence-1)

View File

@@ -0,0 +1,25 @@
[res.on.macro.definitions]
# 16 Library introduction [[library]](./#library)
## 16.4 Library-wide requirements [[requirements]](requirements#res.on.macro.definitions)
### 16.4.6 Conforming implementations [[conforming]](conforming#res.on.macro.definitions)
#### 16.4.6.3 Restrictions on macro definitions [res.on.macro.definitions]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3628)
The names and global function signatures described in [[contents]](contents "16.4.2.2Library contents") are
reserved to the implementation[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3637)
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[.](#2.sentence-1)

View File

@@ -0,0 +1,42 @@
[res.on.objects]
# 16 Library introduction [[library]](./#library)
## 16.4 Library-wide requirements [[requirements]](requirements#res.on.objects)
### 16.4.5 Constraints on programs [[constraints]](constraints#res.on.objects)
#### 16.4.5.10 Library object access [res.on.objects]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3543)
The behavior of a program is undefined if calls to standard library functions from different
threads may introduce a data race[.](#1.sentence-1)
The conditions under which this may occur are specified
in [[res.on.data.races]](res.on.data.races "16.4.6.10Data race avoidance")[.](#1.sentence-2)
[*Note [1](#note-1)*:
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 shareable without data races or the user supplies a locking mechanism[.](#1.sentence-3)
— *end note*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3553)
If an object of a standard library type is accessed, and
the beginning of the object's [lifetime](basic.life "6.8.4Lifetime[basic.life]") 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[.](#2.sentence-1)
[*Note [2](#note-2)*:
This applies even to objects such as mutexes intended for thread synchronization[.](#2.sentence-2)
— *end note*]

View File

@@ -0,0 +1,34 @@
[res.on.requirements]
# 16 Library introduction [[library]](./#library)
## 16.4 Library-wide requirements [[requirements]](requirements#res.on.requirements)
### 16.4.5 Constraints on programs [[constraints]](constraints#res.on.requirements)
#### 16.4.5.11 Semantic requirements [res.on.requirements]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3565)
A sequence Args of template arguments is said to[*model*](#def:model,concept "16.4.5.11Semantic requirements[res.on.requirements]") a concept C if Args satisfies C ([[temp.constr.decl]](temp.constr.decl "13.5.3Constrained declarations")) and
meets all semantic requirements (if any)
given in the specification of C[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3574)
If the validity or meaning of a program
depends on whether a sequence of template arguments models a concept, and
the concept is satisfied but not modeled,
the program is ill-formed, no diagnostic required[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3580)
If the semantic requirements of a declaration's
constraints ([[structure.requirements]](structure.requirements "16.3.2.3Requirements")) are not modeled at the point of use,
the program is ill-formed, no diagnostic required[.](#3.sentence-1)