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

633
cppdraft/constraints.md Normal file
View File

@@ -0,0 +1,633 @@
[constraints]
# 16 Library introduction [[library]](./#library)
## 16.4 Library-wide requirements [[requirements]](requirements#constraints)
### 16.4.5 Constraints on programs [constraints]
#### [16.4.5.1](#overview) Overview [[constraints.overview]](constraints.overview)
[1](#overview-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2978)
Subclause [constraints] describes restrictions on C++ programs that use the facilities of
the C++ standard library[.](#overview-1.sentence-1)
The following subclauses specify constraints on the
program's use of [namespaces](#namespace.std "16.4.5.2.1Namespace std[namespace.std]"), its use of various [reserved
names](#reserved.names "16.4.5.3Reserved names[reserved.names]"), its use of [headers](#alt.headers "16.4.5.4Headers[alt.headers]"), its use of
standard library classes as base classes ([[derived.classes]](#derived.classes "16.4.5.5Derived classes")), its
definitions of [replacement functions](#replacement.functions "16.4.5.6Replacement functions[replacement.functions]"), and its
installation of [handler functions](#handler.functions "16.4.5.7Handler functions[handler.functions]") during execution[.](#overview-1.sentence-2)
#### [16.4.5.2](#namespace.constraints) Namespace use [[namespace.constraints]](namespace.constraints)
#### [16.4.5.2.1](#namespace.std) Namespace std [[namespace.std]](namespace.std)
[1](#namespace.std-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2991)
Unless otherwise specified,
the behavior of a C++ program is undefined if it adds declarations or definitions to namespacestd or to a namespace within namespacestd[.](#namespace.std-1.sentence-1)
[2](#namespace.std-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2998)
Unless explicitly prohibited,
a program may add a template specialization for
any standard library class template
to namespacestd provided that
- [(2.1)](#namespace.std-2.1)
the added declaration
depends on at least one program-defined type, and
- [(2.2)](#namespace.std-2.2)
the specialization meets the standard library requirements
for the original template[.](#namespace.std-2.sentence-1)[151](#footnote-151 "Any library code that instantiates other library templates must be prepared to work adequately with any user-supplied specialization that meets the minimum requirements of this document.")
[3](#namespace.std-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3018)
The behavior of a C++ program is undefined
if it declares an explicit or partial specialization
of any standard library variable template,
except where explicitly permitted by the specification of that variable template[.](#namespace.std-3.sentence-1)
[*Note [1](#namespace.std-note-1)*:
The requirements on an explicit or partial specialization
are stated by each variable template that grants such permission[.](#namespace.std-3.sentence-2)
— *end note*]
[4](#namespace.std-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3028)
The behavior of a C++ program is undefined if it declares
- [(4.1)](#namespace.std-4.1)
an explicit specialization of any member function of a standard
library class template, or
- [(4.2)](#namespace.std-4.2)
an explicit specialization of any member function template of a
standard library class or class template, or
- [(4.3)](#namespace.std-4.3)
an explicit or partial specialization of any member class template
of a standard library class or class template, or
- [(4.4)](#namespace.std-4.4)
a deduction guide for any standard library class template[.](#namespace.std-4.sentence-1)
[5](#namespace.std-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3043)
A program may explicitly instantiate
a class template defined in the standard library
only if the declaration
- [(5.1)](#namespace.std-5.1)
depends on the name of at least one program-defined type, and
- [(5.2)](#namespace.std-5.2)
the instantiation meets the standard library requirements for the
original template[.](#namespace.std-5.sentence-1)
[6](#namespace.std-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3054)
Let *F* denote
a standard library function ([[global.functions]](global.functions "16.4.6.4Non-member functions")),
a standard library static member function,
or an instantiation
of a standard library function template[.](#namespace.std-6.sentence-1)
Unless *F* is designated
an [*addressable function*](#def:function,addressable "16.4.5.2.1Namespace std[namespace.std]"),
the behavior of a C++ program is unspecified (possibly ill-formed)
if it explicitly or implicitly attempts
to form a pointer
to *F*[.](#namespace.std-6.sentence-2)
[*Note [2](#namespace.std-note-2)*:
Possible means of forming such pointers include
application of the unary & operator ([[expr.unary.op]](expr.unary.op "7.6.2.2Unary operators")),addressof ([[specialized.addressof]](specialized.addressof "20.2.11addressof")),
or
a function-to-pointer standard conversion ([[conv.func]](conv.func "7.3.4Function-to-pointer conversion"))[.](#namespace.std-6.sentence-3)
— *end note*]
Moreover,
the behavior of a C++ program is unspecified (possibly ill-formed)
if it attempts to form a reference
to *F* or
if it attempts to form a pointer-to-member designating
either a standard library non-static member function ([[member.functions]](member.functions "16.4.6.5Member functions"))
or an instantiation of a standard library member function template[.](#namespace.std-6.sentence-4)
[7](#namespace.std-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3082)
Let *F* denote
a standard library function or function template[.](#namespace.std-7.sentence-1)
Unless *F* is designated an addressable function,
it is unspecified if or how
a reflection value designating the associated entity can be formed[.](#namespace.std-7.sentence-2)
[*Note [3](#namespace.std-note-3)*:
For example, it is possible that std::meta::members_of will not return reflections of standard library functions
that an implementation handles through an extra-linguistic mechanism[.](#namespace.std-7.sentence-3)
— *end note*]
[8](#namespace.std-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3095)
Let *C* denote
a standard library class or class template specialization[.](#namespace.std-8.sentence-1)
It is unspecified if or how
a reflection value can be formed to any private member of *C*,
or what the names of such members may be[.](#namespace.std-8.sentence-2)
[9](#namespace.std-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3102)
A translation unit shall not declare namespace std to be an inline namespace ([[namespace.def]](namespace.def "9.9.2Namespace definition"))[.](#namespace.std-9.sentence-1)
[151)](#footnote-151)[151)](#footnoteref-151)
Any
library code that instantiates other library templates
must be prepared to work adequately with any user-supplied specialization
that meets the minimum requirements of this document[.](#footnote-151.sentence-1)
#### [16.4.5.2.2](#namespace.posix) Namespace posix [[namespace.posix]](namespace.posix)
[1](#namespace.posix-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3107)
The behavior of a C++ program is undefined if it adds declarations or definitions to namespaceposix or to a namespace within namespaceposix unless otherwise specified[.](#namespace.posix-1.sentence-1)
The namespace posix is reserved for use by
ISO/IEC/IEEE 9945 and other POSIX standards[.](#namespace.posix-1.sentence-2)
#### [16.4.5.2.3](#namespace.future) Namespaces for future standardization [[namespace.future]](namespace.future)
[1](#namespace.future-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3117)
Top-level namespaces whose [*namespace-name*](namespace.def.general#nt:namespace-name "9.9.2.1General[namespace.def.general]") consists of std followed by one or more [*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]")*s* ([[lex.name]](lex.name "5.11Identifiers"))
are reserved for future standardization[.](#namespace.future-1.sentence-1)
The behavior of a C++ program is undefined if
it adds declarations or definitions to such a namespace[.](#namespace.future-1.sentence-2)
[*Example [1](#namespace.future-example-1)*:
The top-level namespace std2 is reserved
for use by future revisions of this International Standard[.](#namespace.future-1.sentence-3)
— *end example*]
#### [16.4.5.3](#reserved.names) Reserved names [[reserved.names]](reserved.names)
#### [16.4.5.3.1](#reserved.names.general) General [[reserved.names.general]](reserved.names.general)
[1](#reserved.names.general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3133)
The C++ standard library reserves the following kinds of names:
- [(1.1)](#reserved.names.general-1.1)
macros
- [(1.2)](#reserved.names.general-1.2)
global names
- [(1.3)](#reserved.names.general-1.3)
names with external linkage
[2](#reserved.names.general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3141)
If a program declares or defines a name in a context where it is
reserved, other than as explicitly allowed by [[library]](library "16Library introduction"), its behavior is
undefined[.](#reserved.names.general-2.sentence-1)
#### [16.4.5.3.2](#zombie.names) Zombie names [[zombie.names]](zombie.names)
[1](#zombie.names-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3152)
In namespace std, the names shown in Table [38](#tab:zombie.names.std "Table 38: Zombie names in namespace std") are
reserved for previous standardization:
Table [38](#tab:zombie.names.std) — Zombie names in namespace std [[tab:zombie.names.std]](./tab:zombie.names.std)
| [🔗](#tab:zombie.names.std-row-1)<br> auto_ptr | generate_header | pointer_to_binary_function |
| --- | --- | --- |
| [🔗](#tab:zombie.names.std-row-2)<br> auto_ptr_ref | get_pointer_safety | pointer_to_unary_function |
| [🔗](#tab:zombie.names.std-row-3)<br> binary_function | get_temporary_buffer | ptr_fun |
| [🔗](#tab:zombie.names.std-row-4)<br> binary_negate | get_unexpected | random_shuffle |
| [🔗](#tab:zombie.names.std-row-5)<br> bind1st | gets | raw_storage_iterator |
| [🔗](#tab:zombie.names.std-row-6)<br> bind2nd | is_literal_type | result_of |
| [🔗](#tab:zombie.names.std-row-7)<br> binder1st | is_literal_type_v | result_of_t |
| [🔗](#tab:zombie.names.std-row-8)<br> binder2nd | istrstream | return_temporary_buffer |
| [🔗](#tab:zombie.names.std-row-9)<br> codecvt_mode | little_endian | set_unexpected |
| [🔗](#tab:zombie.names.std-row-10)<br> codecvt_utf16 | mem_fun1_ref_t | strstream |
| [🔗](#tab:zombie.names.std-row-11)<br> codecvt_utf8 | mem_fun1_t | strstreambuf |
| [🔗](#tab:zombie.names.std-row-12)<br> codecvt_utf8_utf16 | mem_fun_ref_t | unary_function |
| [🔗](#tab:zombie.names.std-row-13)<br> const_mem_fun1_ref_t | mem_fun_ref | unary_negate |
| [🔗](#tab:zombie.names.std-row-14)<br> const_mem_fun1_t | mem_fun_t | uncaught_exception |
| [🔗](#tab:zombie.names.std-row-15)<br> const_mem_fun_ref_t | mem_fun | undeclare_no_pointers |
| [🔗](#tab:zombie.names.std-row-16)<br> const_mem_fun_t | not1 | undeclare_reachable |
| [🔗](#tab:zombie.names.std-row-17)<br> consume_header | not2 | unexpected_handler |
| [🔗](#tab:zombie.names.std-row-18)<br> declare_no_pointers | ostrstream | wbuffer_convert |
| [🔗](#tab:zombie.names.std-row-19)<br> declare_reachable | pointer_safety | wstring_convert |
[2](#zombie.names-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3220)
The names shown in Table [39](#tab:zombie.names.objmacro "Table 39: Zombie object-like macros") are reserved as members for
previous standardization, and may not be used as a name for object-like macros
in portable code:
Table [39](#tab:zombie.names.objmacro) — Zombie object-like macros [[tab:zombie.names.objmacro]](./tab:zombie.names.objmacro)
| [🔗](#tab:zombie.names.objmacro-row-1)<br> argument_type | op | second_argument_type |
| --- | --- | --- |
| [🔗](#tab:zombie.names.objmacro-row-2)<br> first_argument_type | open_mode | seek_dir |
| [🔗](#tab:zombie.names.objmacro-row-3)<br> io_state | preferred | strict |
[3](#zombie.names-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3241)
The names shown in Table [40](#tab:zombie.names.fnmacro "Table 40: Zombie function-like macros") are reserved as member functions
for previous standardization, and may not be used as a name for function-like
macros in portable code:
Table [40](#tab:zombie.names.fnmacro) — Zombie function-like macros [[tab:zombie.names.fnmacro]](./tab:zombie.names.fnmacro)
| [🔗](#tab:zombie.names.fnmacro-row-1)<br> converted | freeze | from_bytes | pcount | stossc | to_bytes |
| --- | --- | --- | --- | --- | --- |
[4](#zombie.names-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3261)
The header names shown in Table [41](#tab:zombie.names.header "Table 41: Zombie headers") are reserved for previous
standardization:
Table [41](#tab:zombie.names.header) — Zombie headers [[tab:zombie.names.header]](./tab:zombie.names.header)
| [🔗](#tab:zombie.names.header-row-1)<br><ccomplex> | <codecvt> | <cstdbool> | <ctgmath> | <strstream> |
| --- | --- | --- | --- | --- |
| [🔗](#tab:zombie.names.header-row-2)<br><ciso646> | <cstdalign> | | | |
#### [16.4.5.3.3](#macro.names) Macro names [[macro.names]](macro.names)
[1](#macro.names-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3282)
A translation unit that includes a standard library header shall not#define or #undef names declared in any standard
library header[.](#macro.names-1.sentence-1)
#### [16.4.5.3.4](#extern.names) External linkage [[extern.names]](extern.names)
[1](#extern.names-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3291)
Each name declared as an object with external linkagein a header is reserved to the implementation to designate that library
object with external linkage,[152](#footnote-152 "The list of such reserved names includes errno, declared or defined in <cerrno>.") both in namespace std and in the global namespace[.](#extern.names-1.sentence-1)
[2](#extern.names-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3303)
Eachglobal function signature declared withexternal linkage in a header is reserved to the
implementation to designate that function signature withexternal linkage[.](#extern.names-2.sentence-1)[153](#footnote-153 "The list of such reserved function signatures with external linkage includes setjmp(jmp_­buf), declared or defined in <csetjmp>, and va_­end(va_­list), declared or defined in <cstdarg>.")
[3](#extern.names-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3326)
Each name from the C standard library declared with external linkageis reserved to the implementation for use as a name withextern "C" linkage,
both in namespace std and in the global namespace[.](#extern.names-3.sentence-1)
[4](#extern.names-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3336)
Each function signature from the C standard library declared withexternal linkage
is reserved to the implementation for use as
a function signature with bothextern "C" andextern "C++" linkage,[154](#footnote-154 "The function signatures declared in <cuchar>, <cwchar>, and <cwctype> are always reserved, notwithstanding the restrictions imposed in subclause 4.5.1 of Amendment 1 to the C Standard for these headers.") or as a name of namespace scope in the global namespace[.](#extern.names-4.sentence-1)
[152)](#footnote-152)[152)](#footnoteref-152)
The list of such reserved names includeserrno, declared or defined in [<cerrno>](errno.general#header:%3ccerrno%3e "19.4.1General[errno.general]")[.](#footnote-152.sentence-1)
[153)](#footnote-153)[153)](#footnoteref-153)
The list of such reserved function
signatures with external linkage includessetjmp(jmp_buf),
declared or defined in [<csetjmp>](csetjmp.syn#header:%3ccsetjmp%3e "17.14.3Header <csetjmp> synopsis[csetjmp.syn]"),
andva_end(va_list),
declared or defined in[<cstdarg>](cstdarg.syn#header:%3ccstdarg%3e "17.14.2Header <cstdarg> synopsis[cstdarg.syn]")[.](#footnote-153.sentence-1)
[154)](#footnote-154)[154)](#footnoteref-154)
The function signatures declared in[<cuchar>](cuchar.syn#header:%3ccuchar%3e "28.7.4Header <cuchar> synopsis[cuchar.syn]"),[<cwchar>](cwchar.syn#header:%3ccwchar%3e "28.7.3Header <cwchar> synopsis[cwchar.syn]"),
and[<cwctype>](cwctype.syn#header:%3ccwctype%3e "28.7.2Header <cwctype> synopsis[cwctype.syn]") are always reserved, notwithstanding the restrictions imposed in subclause
4.5.1 of Amendment 1 to the C Standard for these headers[.](#footnote-154.sentence-1)
#### [16.4.5.3.5](#extern.types) Types [[extern.types]](extern.types)
[1](#extern.types-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3362)
For each type T from the C standard library,
the types::T andstd::T are reserved to the implementation and, when defined,::T shall be identical tostd::T[.](#extern.types-1.sentence-1)
#### [16.4.5.3.6](#usrlit.suffix) User-defined literal suffixes [[usrlit.suffix]](usrlit.suffix)
[1](#usrlit.suffix-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3375)
Literal suffix identifiers ([[over.literal]](over.literal "12.6User-defined literals")) that do not start with an underscore are reserved for future standardization[.](#usrlit.suffix-1.sentence-1)
Literal suffix identifiers that contain a double underscore__are reserved for use by C++ implementations[.](#usrlit.suffix-1.sentence-2)
#### [16.4.5.4](#alt.headers) Headers [[alt.headers]](alt.headers)
[1](#alt.headers-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3384)
If a file with a name
equivalent to the derived file name for one of the C++ standard library headers
is not provided as part of the implementation, and a file with that name
is placed in any of the standard places for a source file to be [included](cpp.include "15.3Source file inclusion[cpp.include]"),
the behavior is undefined[.](#alt.headers-1.sentence-1)
#### [16.4.5.5](#derived.classes) Derived classes [[derived.classes]](derived.classes)
[1](#derived.classes-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3395)
Virtual member function signatures definedfor a base class in the C++ standardlibrary may be overridden in a derived class defined in the program ([[class.virtual]](class.virtual "11.7.3Virtual functions"))[.](#derived.classes-1.sentence-1)
#### [16.4.5.6](#replacement.functions) Replacement functions [[replacement.functions]](replacement.functions)
[1](#replacement.functions-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3405)
If a function defined in[[support]](support "17Language support library") through [[exec]](exec "33Execution control library") and [[depr]](depr "Annex D(normative)Compatibility features") is specified as replaceable ([[dcl.fct.def.replace]](dcl.fct.def.replace#term.replaceable.function "9.6.5Replaceable function definitions")),
the description of function semantics apply
to both the default version defined by the C++ standard library and
the replacement function defined by the program[.](#replacement.functions-1.sentence-1)
#### [16.4.5.7](#handler.functions) Handler functions [[handler.functions]](handler.functions)
[1](#handler.functions-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3415)
The C++ standard library provides a default version of the following handler
function ([[support]](support "17Language support library")):
- [(1.1)](#handler.functions-1.1)
terminate_handler
[2](#handler.functions-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3424)
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):
- [(2.1)](#handler.functions-2.1)
set_new_handler
- [(2.2)](#handler.functions-2.2)
set_terminate
See also subclauses [[alloc.errors]](alloc.errors "17.6.4Storage allocation errors"), Storage allocation errors, and [[support.exception]](support.exception "17.9Exception handling"),
Exception handling[.](#handler.functions-2.sentence-1)
[3](#handler.functions-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3435)
A C++ program can get a pointer to the current handler function by calling the following
functions:
- [(3.1)](#handler.functions-3.1)
get_new_handler
- [(3.2)](#handler.functions-3.2)
get_terminate
[4](#handler.functions-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L3447)
Calling the set_* and get_* functions shall not incur a data race ([[intro.races]](intro.races "6.10.2.2Data races"))[.](#handler.functions-4.sentence-1)
A call to any of the set_* functions synchronizes with subsequent calls to the sameset_* function and to the corresponding get_* function[.](#handler.functions-4.sentence-2)
#### [16.4.5.8](#res.on.functions) Other functions [[res.on.functions]](res.on.functions)
[1](#res.on.functions-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[.](#res.on.functions-1.sentence-1)
If these components do not meet their requirements, this document places no requirements
on the implementation[.](#res.on.functions-1.sentence-2)
[2](#res.on.functions-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)](#res.on.functions-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[.](#res.on.functions-2.1.sentence-1)
- [(2.2)](#res.on.functions-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[.](#res.on.functions-2.2.sentence-1)
- [(2.3)](#res.on.functions-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"))[.](#res.on.functions-2.3.sentence-1)
Operations on such types can report a failure by throwing an exception
unless otherwise specified[.](#res.on.functions-2.3.sentence-2)
- [(2.4)](#res.on.functions-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[.](#res.on.functions-2.4.sentence-1)
- [(2.5)](#res.on.functions-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[.](#res.on.functions-2.5.sentence-1)
#### [16.4.5.9](#res.on.arguments) Function arguments [[res.on.arguments]](res.on.arguments)
[1](#res.on.arguments-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[.](#res.on.arguments-1.sentence-1)
- [(1.1)](#res.on.arguments-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[.](#res.on.arguments-1.1.sentence-1)
- [(1.2)](#res.on.arguments-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[.](#res.on.arguments-1.2.sentence-1)
- [(1.3)](#res.on.arguments-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"))[.](#res.on.arguments-1.3.sentence-1)
[*Note [1](#res.on.arguments-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[.](#res.on.arguments-1.3.sentence-2)
— *end note*]
[*Note [2](#res.on.arguments-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[.](#res.on.arguments-1.3.sentence-3)
The implementation
is free to optimize away aliasing checks which would possibly be needed if the argument was
an lvalue[.](#res.on.arguments-1.3.sentence-4)
— *end note*]
#### [16.4.5.10](#res.on.objects) Library object access [[res.on.objects]](res.on.objects)
[1](#res.on.objects-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[.](#res.on.objects-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")[.](#res.on.objects-1.sentence-2)
[*Note [1](#res.on.objects-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[.](#res.on.objects-1.sentence-3)
— *end note*]
[2](#res.on.objects-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[.](#res.on.objects-2.sentence-1)
[*Note [2](#res.on.objects-note-2)*:
This applies even to objects such as mutexes intended for thread synchronization[.](#res.on.objects-2.sentence-2)
— *end note*]
#### [16.4.5.11](#res.on.requirements) Semantic requirements [[res.on.requirements]](res.on.requirements)
[1](#res.on.requirements-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[.](#res.on.requirements-1.sentence-1)
[2](#res.on.requirements-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[.](#res.on.requirements-2.sentence-1)
[3](#res.on.requirements-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[.](#res.on.requirements-3.sentence-1)