From Jason Turner

[library]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp4kkflxbp/{from.md → to.md} +464 -290
tmp/tmp4kkflxbp/{from.md → to.md} RENAMED
@@ -6,17 +6,16 @@ This Clause describes the contents of the *C++ standard library*, how a
6
  well-formed C++ program makes use of the library, and how a conforming
7
  implementation may provide the entities in the library.
8
 
9
  The following subclauses describe the method of description
10
  [[description]] and organization [[organization]] of the library.
11
- [[requirements]], [[support]] through [[thread]], and [[depr]] specify
12
- the contents of the library, as well as library requirements and
13
- constraints on both well-formed C++ programs and conforming
14
- implementations.
15
 
16
  Detailed specifications for each of the components in the library are in
17
- [[support]]– [[thread]], as shown in [[library.categories]].
18
 
19
  **Table: Library categories** <a id="library.categories">[library.categories]</a>
20
 
21
  | Clause | Category |
22
  | ---------------- | --------------------------- |
@@ -24,23 +23,26 @@ Detailed specifications for each of the components in the library are in
24
  | [[concepts]] | Concepts library |
25
  | [[diagnostics]] | Diagnostics library |
26
  | [[mem]] | Memory management library |
27
  | [[meta]] | Metaprogramming library |
28
  | [[utilities]] | General utilities library |
29
- | [[strings]] | Strings library |
30
  | [[containers]] | Containers library |
31
  | [[iterators]] | Iterators library |
32
  | [[ranges]] | Ranges library |
33
  | [[algorithms]] | Algorithms library |
 
 
34
  | [[numerics]] | Numerics library |
35
  | [[time]] | Time library |
36
- | [[localization]] | Localization library |
37
  | [[input.output]] | Input/output library |
38
- | [[re]] | Regular expressions library |
39
  | [[thread]] | Concurrency support library |
 
40
 
41
 
 
 
 
42
  The language support library [[support]] provides components that are
43
  required by certain parts of the C++ language, such as memory allocation
44
  [[expr.new]], [[expr.delete]] and exception processing [[except]].
45
 
46
  The concepts library [[concepts]] describes library components that C++
@@ -61,69 +63,70 @@ sequences, and rational arithmetic.
61
  The general utilities library [[utilities]] includes components used by
62
  other library elements, such as a predefined storage allocator for
63
  dynamic storage management [[basic.stc.dynamic]], and components used as
64
  infrastructure in C++ programs, such as tuples and function wrappers.
65
 
66
- The strings library [[strings]] provides support for manipulating text
67
- represented as sequences of type `char`, sequences of type `char8_t`,
68
- sequences of type `char16_t`, sequences of type `char32_t`, sequences of
69
- type `wchar_t`, and sequences of any other character-like type.
70
-
71
  The containers [[containers]], iterators [[iterators]], ranges
72
  [[ranges]], and algorithms [[algorithms]] libraries provide a C++
73
  program with access to a subset of the most widely used algorithms and
74
  data structures.
75
 
 
 
 
 
 
 
 
 
 
76
  The numerics library [[numerics]] provides numeric algorithms and
77
  complex number components that extend support for numeric processing.
78
  The `valarray` component provides support for *n*-at-a-time processing,
79
  potentially implemented as parallel operations on platforms that support
80
  such processing. The random number component provides facilities for
81
  generating pseudo-random numbers.
82
 
83
  The time library [[time]] provides generally useful time utilities.
84
 
85
- The localization library [[localization]] provides extended
86
- internationalization support for text processing.
87
-
88
  The input/output library [[input.output]] provides the `iostream`
89
  components that are the primary mechanism for C++ program input and
90
  output. They can be used with other elements of the library,
91
  particularly strings, locales, and iterators.
92
 
93
- The regular expressions library [[re]] provides regular expression
94
- matching and searching.
95
-
96
  The concurrency support library [[thread]] provides components to create
97
  and manage threads, including atomic operations, mutual exclusion, and
98
  interthread communication.
99
 
 
 
 
100
  ## The C standard library <a id="library.c">[[library.c]]</a>
101
 
102
  The C++ standard library also makes available the facilities of the C
103
  standard library, suitably adjusted to ensure static type safety.
104
 
105
  The descriptions of many library functions rely on the C standard
106
  library for the semantics of those functions. In some cases, the
107
  signatures specified in this document may be different from the
108
  signatures in the C standard library, and additional overloads may be
109
  declared in this document, but the behavior and the preconditions
110
- (including any preconditions implied by the use of an ISO C `restrict`
111
  qualifier) are the same unless otherwise stated.
112
 
113
  A call to a C standard library function is a non-constant library call
114
  [[defns.nonconst.libcall]] if it raises a floating-point exception other
115
  than `FE_INEXACT`. The semantics of a call to a C standard library
116
  function evaluated as a core constant expression are those specified in
117
- Annex F of the C standard[^1]
118
 
119
  to the extent applicable to the floating-point types
120
  [[basic.fundamental]] that are parameter types of the called function.
121
 
122
- [*Note 1*: Annex F specifies the conditions under which floating-point
123
- exceptions are raised and the behavior when NaNs and/or infinities are
124
- passed as arguments. — *end note*]
125
 
126
  [*Note 2*: Equivalently, a call to a C standard library function is a
127
  non-constant library call if `errno` is set when
128
  `math_errhandling & MATH_ERRNO` is `true`. — *end note*]
129
 
@@ -131,11 +134,11 @@ non-constant library call if `errno` is set when
131
 
132
  ### General <a id="description.general">[[description.general]]</a>
133
 
134
  Subclause [[description]] describes the conventions used to specify the
135
  C++ standard library. [[structure]] describes the structure of
136
- [[support]] through [[thread]] and [[depr]]. [[conventions]] describes
137
  other editorial conventions.
138
 
139
  ### Structure of each clause <a id="structure">[[structure]]</a>
140
 
141
  #### Elements <a id="structure.elements">[[structure.elements]]</a>
@@ -253,54 +256,85 @@ appropriate):[^5]
253
  overload resolution [[over.match]]. \[*Note 1*: Failure to meet such a
254
  condition results in the function’s silent
255
  non-viability. — *end note*] \[*Example 1*: An implementation can
256
  express such a condition via a *constraint-expression*
257
  [[temp.constr.decl]]. — *end example*]
 
258
  - *Mandates:* the conditions that, if not met, render the program
259
  ill-formed. \[*Example 2*: An implementation can express such a
260
  condition via the *constant-expression* in a
261
  *static_assert-declaration* [[dcl.pre]]. If the diagnostic is to be
262
  emitted only after the function has been selected by overload
263
  resolution, an implementation can express such a condition via a
264
  *constraint-expression* [[temp.constr.decl]] and also define the
265
  function as deleted. — *end example*]
266
- - *Preconditions:* the conditions that the function assumes to hold
267
- whenever it is called; violation of any preconditions results in
268
- undefined behavior.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
269
  - *Effects:* the actions performed by the function.
 
270
  - *Synchronization:* the synchronization operations
271
  [[intro.multithread]] applicable to the function.
 
272
  - *Ensures:* the conditions (sometimes termed observable results)
273
- established by the function.
 
 
 
274
  - *Result:* for a *typename-specifier*, a description of the named type;
275
- for an *expression*, a description of the type of the expression; the
276
- expression is an lvalue if the type is an lvalue reference type, an
277
- xvalue if the type is an rvalue reference type, and a prvalue
278
- otherwise.
 
279
  - *Returns:* a description of the value(s) returned by the function.
 
280
  - *Throws:* any exceptions thrown by the function, and the conditions
281
  that would cause the exception.
 
282
  - *Complexity:* the time and/or space complexity of the function.
 
283
  - *Remarks:* additional semantic constraints on the function.
 
284
  - *Error conditions:* the error conditions for error codes reported by
285
  the function.
286
 
287
  Whenever the *Effects* element specifies that the semantics of some
288
  function `F` are *Equivalent to* some code sequence, then the various
289
  elements are interpreted as follows. If `F`’s semantics specifies any
290
  *Constraints* or *Mandates* elements, then those requirements are
291
  logically imposed prior to the *equivalent-to* semantics. Next, the
292
  semantics of the code sequence are determined by the *Constraints*,
293
- *Mandates*, *Preconditions*, *Effects*, *Synchronization*,
294
- *Postconditions*, *Returns*, *Throws*, *Complexity*, *Remarks*, and
295
- *Error conditions* specified for the function invocations contained in
296
- the code sequence. The value returned from `F` is specified by `F`’s
297
- *Returns* element, or if `F` has no *Returns* element, a non-`void`
298
- return from `F` is specified by the `return` statements [[stmt.return]]
299
- in the code sequence. If `F`’s semantics contains a *Throws*,
300
- *Postconditions*, or *Complexity* element, then that supersedes any
301
- occurrences of that element in the code sequence.
 
302
 
303
  For non-reserved replacement and handler functions, [[support]]
304
  specifies two behaviors for the functions in question: their required
305
  and default behavior. The *default behavior* describes a function
306
  definition provided by the implementation. The *required behavior*
@@ -334,27 +368,26 @@ to describe the contents of the C++ standard library. These conventions
334
  are for describing implementation-defined types [[type.descriptions]],
335
  and member functions [[functions.within.classes]].
336
 
337
  #### Exposition-only entities, etc. <a id="expos.only.entity">[[expos.only.entity]]</a>
338
 
339
- Several entities and *typedef-name*s defined in [[support]] through
340
- [[thread]] and [[depr]] are only defined for the purpose of exposition.
341
- The declaration of such an entity or *typedef-name* is followed by a
342
- comment ending in *exposition only*.
343
 
344
  The following are defined for exposition only to aid in the
345
  specification of the library:
346
 
347
  ``` cpp
348
  namespace std {
349
  template<class T>
350
  requires convertible_to<T, decay_t<T>>
351
- constexpr decay_t<T> decay-copy(T&& v)
352
- noexcept(is_nothrow_convertible_v<T, decay_t<T>>) // exposition only
353
  { return std::forward<T>(v); }
354
 
355
- constexpr auto synth-three-way =
356
  []<class T, class U>(const T& t, const U& u)
357
  requires requires {
358
  { t < u } -> boolean-testable;
359
  { u < t } -> boolean-testable;
360
  }
@@ -367,14 +400,24 @@ namespace std {
367
  return weak_ordering::equivalent;
368
  }
369
  };
370
 
371
  template<class T, class U = T>
372
- using synth-three-way-result = decltype(synth-three-way(declval<T&>(), declval<U&>()));
 
373
  }
374
  ```
375
 
 
 
 
 
 
 
 
 
 
376
  #### Type descriptions <a id="type.descriptions">[[type.descriptions]]</a>
377
 
378
  ##### General <a id="type.descriptions.general">[[type.descriptions.general]]</a>
379
 
380
  The Requirements subclauses may describe names that are used to specify
@@ -409,11 +452,11 @@ inline const enumerated C₃(V₃);
409
  Here, the names `C₀`, `C₁`, etc. represent *enumerated elements* for
410
  this particular enumerated type. All such elements have distinct values.
411
 
412
  ##### Bitmask types <a id="bitmask.types">[[bitmask.types]]</a>
413
 
414
- Several types defined in [[support]] through [[thread]] and [[depr]] are
415
  *bitmask types*. Each bitmask type can be implemented as an enumerated
416
  type that overloads certain operators, as an integer type, or as a
417
  `bitset` [[template.bitset]].
418
 
419
  The bitmask type `bitmask` can be written:
@@ -495,20 +538,22 @@ sequences that follow a few uniform conventions:
495
  basic character set.
496
  - The *decimal-point character* is the locale-specific (single-byte)
497
  character used by functions that convert between a (single-byte)
498
  character sequence and a value of one of the floating-point types. It
499
  is used in the character sequence to denote the beginning of a
500
- fractional part. It is represented in [[support]] through [[thread]]
501
- and [[depr]] by a period, `'.'`, which is also its value in the `"C"`
502
  locale.
503
  - A *character sequence* is an array object [[dcl.array]] `A` that can
504
  be declared as `T A[N]`, where `T` is any of the types `char`,
505
  `unsigned char`, or `signed char` [[basic.fundamental]], optionally
506
  qualified by any combination of `const` or `volatile`. The initial
507
  elements of the array have defined contents up to and including an
508
  element determined by some predicate. A character sequence can be
509
  designated by a pointer value `S` that points to its first element.
 
 
510
 
511
  ###### Byte strings <a id="byte.strings">[[byte.strings]]</a>
512
 
513
  A *null-terminated byte string*, or NTBS, is a character sequence whose
514
  highest-addressed element with defined content has the value zero (the
@@ -566,32 +611,64 @@ initialized as if by `auto p = o;`. Then for any sequence of arguments
566
  - `p(args...)`
567
  - `as_const(p)(args...)`
568
  - `std::move(p)(args...)`
569
  - `std::move(as_const(p))(args...)`
570
 
571
- Each customization point object type constrains its return type to model
572
- a particular concept.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
573
 
574
  #### Functions within classes <a id="functions.within.classes">[[functions.within.classes]]</a>
575
 
576
- For the sake of exposition, [[support]] through [[thread]] and [[depr]]
577
- do not describe copy/move constructors, assignment operators, or
578
  (non-virtual) destructors with the same apparent semantics as those that
579
  can be generated by default
580
  [[class.copy.ctor]], [[class.copy.assign]], [[class.dtor]]. It is
581
  unspecified whether the implementation provides explicit definitions for
582
  such member function signatures, or for virtual destructors that can be
583
  generated by default.
584
 
585
  #### Private members <a id="objects.within.classes">[[objects.within.classes]]</a>
586
 
587
- [[support]] through [[thread]] and [[depr]] do not specify the
588
  representation of classes, and intentionally omit specification of class
589
  members [[class.mem]]. An implementation may define static or non-static
590
  class members, or both, as needed to implement the semantics of the
591
- member functions specified in [[support]] through [[thread]] and
592
- [[depr]].
593
 
594
  For the sake of exposition, some subclauses provide representative
595
  declarations, and semantic requirements, for private members of classes
596
  that meet the external specifications of the classes. The declarations
597
  for such members are followed by a comment that ends with *exposition
@@ -604,69 +681,118 @@ streambuf* sb; // exposition only
604
  An implementation may use any technique that provides equivalent
605
  observable behavior.
606
 
607
  #### Freestanding items <a id="freestanding.item">[[freestanding.item]]</a>
608
 
609
- A *freestanding item* is a declaration, entity, *typedef-name*, or macro
610
- that is required to be present in a freestanding implementation and a
611
- hosted implementation.
612
 
613
  Unless otherwise specified, the requirements on freestanding items for a
614
  freestanding implementation are the same as the corresponding
615
  requirements for a hosted implementation, except that not all of the
616
- members of the namespaces are required to be present.
617
 
618
- [*Note 1*: This implies that freestanding item enumerations have the
619
- same enumerators on freestanding implementations and hosted
620
- implementations. Furthermore, class types have the same members and
621
- class templates have the same deduction guides on freestanding
622
- implementations and hosted implementations. *end note*]
 
 
623
 
624
- A declaration in a header synopsis is a freestanding item if
 
 
625
 
626
- - it is followed by a comment that includes *freestanding*, or
627
- - the header synopsis begins with a comment that includes *all
628
- freestanding*.
629
 
630
- An entity or *typedef-name* is a freestanding item if it is:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
631
 
632
  - introduced by a declaration that is a freestanding item,
 
 
 
633
  - an enclosing namespace of a freestanding item,
634
  - a friend of a freestanding item,
635
- - denoted by a *typedef-name* that is a freestanding item, or
636
  - denoted by an alias template that is a freestanding item.
637
 
638
  A macro is a freestanding item if it is defined in a header synopsis and
639
 
640
  - the definition is followed by a comment that includes *freestanding*,
641
  or
642
- - the header synopsis begins with a comment that includes *all
643
- freestanding*.
 
644
 
645
- [*Example 1*:
646
 
647
  ``` cpp
648
  #define NULL see below // freestanding
649
  ```
650
 
651
  — *end example*]
652
 
653
- [*Example 2*:
 
 
 
 
 
 
 
 
 
 
654
 
655
  ``` cpp
656
- // all freestanding
657
- namespace std {
 
 
 
 
 
 
658
  ```
659
 
660
  — *end example*]
661
 
662
  ## Library-wide requirements <a id="requirements">[[requirements]]</a>
663
 
664
  ### General <a id="requirements.general">[[requirements.general]]</a>
665
 
666
  Subclause [[requirements]] specifies requirements that apply to the
667
- entire C++ standard library. [[support]] through [[thread]] and [[depr]]
668
  specify the requirements of individual entities within the library.
669
 
670
  Requirements specified in terms of interactions between threads do not
671
  apply to programs having only a single thread of execution.
672
 
@@ -698,15 +824,15 @@ defined within the namespace `std` or namespaces nested within namespace
698
 
699
  It is unspecified whether names declared in a specific namespace are
700
  declared directly in that namespace or in an inline namespace inside
701
  that namespace.[^13]
702
 
703
- Whenever an unqualified name other than `swap`, `make_error_code`, or
704
- `make_error_condition` is used in the specification of a declaration `D`
705
- in [[support]] through [[thread]] or [[depr]], its meaning is
706
- established as-if by performing unqualified name lookup
707
- [[basic.lookup.unqual]] in the context of `D`.
708
 
709
  [*Note 1*: Argument-dependent lookup is not performed. — *end note*]
710
 
711
  Similarly, the meaning of a *qualified-id* is established as-if by
712
  performing qualified name lookup [[basic.lookup.qual]] in the context of
@@ -719,13 +845,14 @@ performing qualified name lookup [[basic.lookup.qual]] in the context of
719
  [*Note 2*: Operators in expressions [[over.match.oper]] are not so
720
  constrained; see [[global.functions]]. — *end note*]
721
 
722
  The meaning of the unqualified name `swap` is established in an overload
723
  resolution context for swappable values [[swappable.requirements]]. The
724
- meanings of the unqualified names `make_error_code` and
725
- `make_error_condition` are established as-if by performing
726
- argument-dependent lookup [[basic.lookup.argdep]].
 
727
 
728
  #### Headers <a id="headers">[[headers]]</a>
729
 
730
  Each element of the C++ standard library is declared or defined (as
731
  appropriate) in a *header*.[^14]
@@ -751,18 +878,18 @@ import <vector>; // imports the <vector> header unit
751
  std::vector<int> vi; // OK
752
  ```
753
 
754
  — *end example*]
755
 
756
- Except as noted in [[library]] through [[thread]] and [[depr]], the
757
  contents of each header `cname` is the same as that of the corresponding
758
  header `name.h` as specified in the C standard library [[intro.refs]].
759
  In the C++ standard library, however, the declarations (except for names
760
  which are defined as macros in C) are within namespace scope
761
  [[basic.scope.namespace]] of the namespace `std`. It is unspecified
762
  whether these names (including any overloads added in [[support]]
763
- through [[thread]] and [[depr]]) are first declared within the global
764
  namespace scope and are then injected into namespace `std` by explicit
765
  *using-declaration*s [[namespace.udecl]].
766
 
767
  Names which are defined as macros in C shall be defined as macros in the
768
  C++ standard library, even if C grants license for implementation as
@@ -776,15 +903,15 @@ Names that are defined as functions in C shall be defined as functions
776
  in the C++ standard library.[^16]
777
 
778
  Identifiers that are keywords or operators in C++ shall not be defined
779
  as macros in C++ standard library headers.[^17]
780
 
781
- [[support.c.headers]], C standard library headers, describes the effects
782
- of using the `name.h` (C header) form in a C++ program.[^18]
783
 
784
- Annex K of the C standard describes a large number of functions, with
785
- associated types and macros, which “promote safer, more secure
786
  programming” than many of the traditional C library functions. The names
787
  of the functions have a suffix of `_s`; most of them provide the same
788
  service as the C library function with the unsuffixed name, but
789
  generally take an additional argument whose value is the size of the
790
  result array. If any C++ header is included, it is
@@ -805,21 +932,23 @@ subset provided by a freestanding implementation) and the C++ headers
805
  for C library facilities ([[headers.cpp.c]]). It additionally exports
806
  declarations in the global namespace for the storage allocation and
807
  deallocation functions that are provided by `<new>`.
808
 
809
  The named module `std.compat` exports the same declarations as the named
810
- module `std`, and additionally exports declarations in the global
811
- namespace corresponding to the declarations in namespace `std` that are
812
- provided by the C++ headers for C library facilities (
813
- [[headers.cpp.c]]), except the explicitly excluded declarations
814
- described in [[support.c.headers.other]].
 
 
815
 
816
  It is unspecified to which module a declaration in the standard library
817
  is attached.
818
 
819
- [*Note 1*: Implementations are required to ensure that mixing
820
- `#include` and `import` does not result in conflicting attachments
821
  [[basic.link]]. — *end note*]
822
 
823
  *Recommended practice:* Implementations should ensure such attachments
824
  do not preclude further evolution or decomposition of the standard
825
  library modules.
@@ -848,40 +977,80 @@ headers. This set shall include at least the headers shown in
848
  [[headers.cpp.fs]].
849
 
850
  **Table: C++ headers for freestanding implementations** <a id="headers.cpp.fs">[headers.cpp.fs]</a>
851
 
852
  | Subclause | | Header |
853
- | ---------------------- | -------------------------------- | ------------------------------------------------ |
854
  | [[support.types]] | Common definitions | `<cstddef>` |
855
- | [[support.limits]] | Implementation properties | `<cfloat>`, `<climits>`, `<limits>`, `<version>` |
 
 
856
  | [[cstdint.syn]] | Integer types | `<cstdint>` |
857
- | [[support.start.term]] | Start and termination | `<cstdlib>` |
858
  | [[support.dynamic]] | Dynamic memory management | `<new>` |
859
  | [[support.rtti]] | Type identification | `<typeinfo>` |
860
  | [[support.srcloc]] | Source location | `<source_location>` |
861
  | [[support.exception]] | Exception handling | `<exception>` |
862
  | [[support.initlist]] | Initializer lists | `<initializer_list>` |
863
  | [[cmp]] | Comparisons | `<compare>` |
 
864
  | [[support.coroutine]] | Coroutines support | `<coroutine>` |
865
  | [[support.runtime]] | Other runtime support | `<cstdarg>` |
866
  | [[concepts]] | Concepts library | `<concepts>` |
 
 
 
 
867
  | [[type.traits]] | Type traits | `<type_traits>` |
868
- | [[bit]] | Bit manipulation | `<bit>` |
869
- | [[atomics]] | Atomics | `<atomic>` |
870
  | [[utility]] | Utility components | `<utility>` |
871
  | [[tuple]] | Tuples | `<tuple>` |
872
- | [[memory]] | Memory | `<memory>` |
 
 
873
  | [[function.objects]] | Function objects | `<functional>` |
874
- | [[ratio]] | Compile-time rational arithmetic | `<ratio>` |
 
 
 
 
 
875
  | [[iterators]] | Iterators library | `<iterator>` |
876
  | [[ranges]] | Ranges library | `<ranges>` |
 
 
 
 
 
 
 
 
 
877
 
878
 
879
  For each of the headers listed in [[headers.cpp.fs]], a freestanding
880
  implementation provides at least the freestanding items
881
  [[freestanding.item]] declared in the header.
882
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
883
  ### Using the library <a id="using">[[using]]</a>
884
 
885
  #### Overview <a id="using.overview">[[using.overview]]</a>
886
 
887
  Subclause [[using]] describes how a C++ program gains access to the
@@ -1018,21 +1187,21 @@ signatures is called using the default argument [[dcl.fct.default]].
1018
 
1019
  **Table: Cpp17Destructible requirements** <a id="cpp17.destructible">[cpp17.destructible]</a>
1020
 
1021
  | Expression | Post-condition |
1022
  | ---------- | --------------------------------------------------------------------- |
1023
- | `u.~T()` | All resources owned by `u` are reclaimed, no exception is propagated. |
1024
  | *[spans 2 columns]* *Array types and non-object types are not Cpp17Destructible.* |
1025
 
1026
 
1027
  #### Swappable requirements <a id="swappable.requirements">[[swappable.requirements]]</a>
1028
 
1029
  This subclause provides definitions for swappable types and expressions.
1030
  In these definitions, let `t` denote an expression of type `T`, and let
1031
  `u` denote an expression of type `U`.
1032
 
1033
- An object `t` is *swappable with* an object `u` if and only if:
1034
 
1035
  - the expressions `swap(t, u)` and `swap(u, t)` are valid when evaluated
1036
  in the context described below, and
1037
  - these expressions have the following effects:
1038
  - the object referred to by `t` has the value originally held by `u`
@@ -1058,16 +1227,15 @@ swappable requirement includes the header `<utility>` to ensure an
1058
  appropriate evaluation context. — *end note*]
1059
 
1060
  An rvalue or lvalue `t` is *swappable* if and only if `t` is swappable
1061
  with any rvalue or lvalue, respectively, of type `T`.
1062
 
1063
- A type `X` meets the *Cpp17Swappable* requirements if lvalues of type
1064
- `X` are swappable.
1065
 
1066
  A type `X` meeting any of the iterator requirements
1067
- [[iterator.requirements]] meets the *Cpp17ValueSwappable* requirements
1068
- if, for any dereferenceable object `x` of type `X`, `*x` is swappable.
1069
 
1070
  [*Example 1*:
1071
 
1072
  User code can ensure that the evaluation of `swap` calls is performed in
1073
  an appropriate context under the various conditions as follows:
@@ -1117,25 +1285,27 @@ int main() {
1117
  — *end example*]
1118
 
1119
  #### *Cpp17NullablePointer* requirements <a id="nullablepointer.requirements">[[nullablepointer.requirements]]</a>
1120
 
1121
  A *Cpp17NullablePointer* type is a pointer-like type that supports null
1122
- values. A type `P` meets the *Cpp17NullablePointer* requirements if:
1123
 
1124
  - `P` meets the *Cpp17EqualityComparable*, *Cpp17DefaultConstructible*,
1125
  *Cpp17CopyConstructible*, *Cpp17CopyAssignable*, *Cpp17Swappable*, and
1126
  *Cpp17Destructible* requirements,
1127
  - the expressions shown in [[cpp17.nullablepointer]] are valid and have
1128
  the indicated semantics, and
1129
  - `P` meets all the other requirements of this subclause.
1130
 
1131
  A value-initialized object of type `P` produces the null value of the
1132
  type. The null value shall be equivalent only to itself. A
1133
- default-initialized object of type `P` may have an indeterminate value.
 
1134
 
1135
  [*Note 1*: Operations involving indeterminate values can cause
1136
- undefined behavior. *end note*]
 
1137
 
1138
  An object `p` of type `P` can be contextually converted to `bool`
1139
  [[conv]]. The effect shall be as if `p != nullptr` had been evaluated in
1140
  place of `p`.
1141
 
@@ -1162,11 +1332,11 @@ non-`const` lvalue of type `P`, `a` and `b` denote values of type
1162
  | `np != a` | | |
1163
 
1164
 
1165
  #### *Cpp17Hash* requirements <a id="hash.requirements">[[hash.requirements]]</a>
1166
 
1167
- A type `H` meets the requirements if:
1168
 
1169
  - it is a function object type [[function.objects]],
1170
  - it meets the *Cpp17CopyConstructible* ([[cpp17.copyconstructible]])
1171
  and *Cpp17Destructible* ([[cpp17.destructible]]) requirements, and
1172
  - the expressions shown in [[cpp17.hash]] are valid and have the
@@ -1189,15 +1359,15 @@ The library describes a standard set of requirements for *allocators*,
1189
  which are class-type objects that encapsulate the information about an
1190
  allocation model. This information includes the knowledge of pointer
1191
  types, the type of their difference, the type of the size of objects in
1192
  this allocation model, as well as the memory allocation and deallocation
1193
  primitives for it. All of the string types [[strings]], containers
1194
- [[containers]] (except `array`), string buffers and string streams
1195
- [[input.output]], and `match_results` [[re]] are parameterized in terms
1196
- of allocators.
1197
 
1198
- In subclause [[allocator.requirements]],
1199
 
1200
  - `T`, `U`, `C` denote any cv-unqualified object type
1201
  [[term.object.type]],
1202
  - `X` denotes an allocator class for type `T`,
1203
  - `Y` denotes the corresponding allocator class for type `U`,
@@ -1293,11 +1463,11 @@ typename X::difference_type
1293
  between any two pointers in the allocation model.
1294
 
1295
  *Remarks:* Default: `pointer_traits<XX::pointer>::difference_type`
1296
 
1297
  ``` cpp
1298
- typename X::template rebind<U>::other
1299
  ```
1300
 
1301
  *Result:* `Y`
1302
 
1303
  *Ensures:* For all `U` (including `T`), `YY::rebind_alloc<T>` is `X`.
@@ -1524,11 +1694,11 @@ X u(std::move(b));
1524
  *Ensures:* `u` is equal to the prior value of `X(b)`.
1525
 
1526
  *Throws:* Nothing.
1527
 
1528
  ``` cpp
1529
- a.construct(c, args)
1530
  ```
1531
 
1532
  *Result:* (not used)
1533
 
1534
  *Effects:* Constructs an object of type `C` at `c`.
@@ -1693,10 +1863,29 @@ struct SimpleAllocator {
1693
  };
1694
  ```
1695
 
1696
  — *end example*]
1697
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1698
  ##### Allocator completeness requirements <a id="allocator.requirements.completeness">[[allocator.requirements.completeness]]</a>
1699
 
1700
  If `X` is an allocator class for type `T`, `X` additionally meets the
1701
  allocator completeness requirements if, whether or not `T` is a complete
1702
  type:
@@ -1726,13 +1915,16 @@ Unless otherwise specified, the behavior of a C++ program is undefined
1726
  if it adds declarations or definitions to namespace `std` or to a
1727
  namespace within namespace `std`.
1728
 
1729
  Unless explicitly prohibited, a program may add a template
1730
  specialization for any standard library class template to namespace
1731
- `std` provided that (a) the added declaration depends on at least one
1732
- program-defined type and (b) the specialization meets the standard
1733
- library requirements for the original template.[^21]
 
 
 
1734
 
1735
  The behavior of a C++ program is undefined if it declares an explicit or
1736
  partial specialization of any standard library variable template, except
1737
  where explicitly permitted by the specification of that variable
1738
  template.
@@ -1750,13 +1942,15 @@ The behavior of a C++ program is undefined if it declares
1750
  - an explicit or partial specialization of any member class template of
1751
  a standard library class or class template, or
1752
  - a deduction guide for any standard library class template.
1753
 
1754
  A program may explicitly instantiate a class template defined in the
1755
- standard library only if the declaration (a) depends on the name of at
1756
- least one program-defined type and (b) the instantiation meets the
1757
- standard library requirements for the original template.
 
 
1758
 
1759
  Let `F` denote a standard library function [[global.functions]], a
1760
  standard library static member function, or an instantiation of a
1761
  standard library function template. Unless `F` is designated an
1762
  *addressable function*, the behavior of a C++ program is unspecified
@@ -1772,19 +1966,33 @@ Moreover, the behavior of a C++ program is unspecified (possibly
1772
  ill-formed) if it attempts to form a reference to `F` or if it attempts
1773
  to form a pointer-to-member designating either a standard library
1774
  non-static member function [[member.functions]] or an instantiation of a
1775
  standard library member function template.
1776
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1777
  A translation unit shall not declare namespace `std` to be an inline
1778
  namespace [[namespace.def]].
1779
 
1780
  ##### Namespace `posix` <a id="namespace.posix">[[namespace.posix]]</a>
1781
 
1782
  The behavior of a C++ program is undefined if it adds declarations or
1783
  definitions to namespace `posix` or to a namespace within namespace
1784
  `posix` unless otherwise specified. The namespace `posix` is reserved
1785
- for use by ISO/IEC/IEEE 9945 and other POSIX standards.
1786
 
1787
  ##### Namespaces for future standardization <a id="namespace.future">[[namespace.future]]</a>
1788
 
1789
  Top-level namespaces whose *namespace-name* consists of `std` followed
1790
  by one or more *digit*s [[lex.name]] are reserved for future
@@ -1808,89 +2016,29 @@ If a program declares or defines a name in a context where it is
1808
  reserved, other than as explicitly allowed by [[library]], its behavior
1809
  is undefined.
1810
 
1811
  ##### Zombie names <a id="zombie.names">[[zombie.names]]</a>
1812
 
1813
- In namespace `std`, the following names are reserved for previous
1814
- standardization:
1815
 
1816
- - `auto_ptr`,
1817
- - `auto_ptr_ref`,
1818
- - `binary_function`,
1819
- - `binary_negate`,
1820
- - `bind1st`,
1821
- - `bind2nd`,
1822
- - `binder1st`,
1823
- - `binder2nd`,
1824
- - `const_mem_fun1_ref_t`,
1825
- - `const_mem_fun1_t`,
1826
- - `const_mem_fun_ref_t`,
1827
- - `const_mem_fun_t`,
1828
- - `declare_no_pointers`,
1829
- - `declare_reachable`,
1830
- - `get_pointer_safety`,
1831
- - `get_temporary_buffer`,
1832
- - `get_unexpected`,
1833
- - `gets`,
1834
- - `is_literal_type`,
1835
- - `is_literal_type_v`,
1836
- - `mem_fun1_ref_t`,
1837
- - `mem_fun1_t`,
1838
- - `mem_fun_ref_t`,
1839
- - `mem_fun_ref`,
1840
- - `mem_fun_t`,
1841
- - `mem_fun`,
1842
- - `not1`,
1843
- - `not2`,
1844
- - `pointer_safety`,
1845
- - `pointer_to_binary_function`,
1846
- - `pointer_to_unary_function`,
1847
- - `ptr_fun`,
1848
- - `random_shuffle`,
1849
- - `raw_storage_iterator`,
1850
- - `result_of`,
1851
- - `result_of_t`,
1852
- - `return_temporary_buffer`,
1853
- - `set_unexpected`,
1854
- - `unary_function`,
1855
- - `unary_negate`,
1856
- - `uncaught_exception`,
1857
- - `undeclare_no_pointers`,
1858
- - `undeclare_reachable`, and
1859
- - `unexpected_handler`.
1860
 
1861
- The following names are reserved as members for previous
1862
- standardization, and may not be used as a name for object-like macros in
1863
- portable code:
1864
 
1865
- - `argument_type`,
1866
- - `first_argument_type`,
1867
- - `io_state`,
1868
- - `open_mode`,
1869
- - `preferred`,
1870
- - `second_argument_type`,
1871
- - `seek_dir`, and.
1872
- - `strict`.
1873
-
1874
- The name `stossc` is reserved as a member function for previous
1875
- standardization, and may not be used as a name for function-like macros
1876
- in portable code.
1877
-
1878
- The header names `<ccomplex>`, `<ciso646>`, `<cstdalign>`, `<cstdbool>`,
1879
- and `<ctgmath>` are reserved for previous standardization.
1880
 
1881
  ##### Macro names <a id="macro.names">[[macro.names]]</a>
1882
 
1883
  A translation unit that includes a standard library header shall not
1884
  `#define` or `#undef` names declared in any standard library header.
1885
 
1886
- A translation unit shall not `#define` or `#undef` names lexically
1887
- identical to keywords, to the identifiers listed in
1888
- [[lex.name.special]], or to the *attribute-token*s described in 
1889
- [[dcl.attr]], except that the names `likely` and `unlikely` may be
1890
- defined as function-like macros  [[cpp.replace]].
1891
-
1892
  ##### External linkage <a id="extern.names">[[extern.names]]</a>
1893
 
1894
  Each name declared as an object with external linkage in a header is
1895
  reserved to the implementation to designate that library object with
1896
  external linkage, [^22]
@@ -1938,56 +2086,15 @@ Virtual member function signatures defined for a base class in the C++
1938
  standard library may be overridden in a derived class defined in the
1939
  program [[class.virtual]].
1940
 
1941
  #### Replacement functions <a id="replacement.functions">[[replacement.functions]]</a>
1942
 
1943
- [[support]] through [[thread]] and [[depr]] describe the behavior of
1944
- numerous functions defined by the C++ standard library. Under some
1945
- circumstances, however, certain of these function descriptions also
1946
- apply to replacement functions defined in the program.
1947
-
1948
- A C++ program may provide the definition for any of the following
1949
- dynamic memory allocation function signatures declared in header `<new>`
1950
- [[basic.stc.dynamic]], [[new.syn]]:
1951
-
1952
- ``` cpp
1953
- operator new(std::size_t)
1954
- operator new(std::size_t, std::align_val_t)
1955
- operator new(std::size_t, const std::nothrow_t&)
1956
- operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
1957
- ```
1958
-
1959
- ``` cpp
1960
- operator delete(void*)
1961
- operator delete(void*, std::size_t)
1962
- operator delete(void*, std::align_val_t)
1963
- operator delete(void*, std::size_t, std::align_val_t)
1964
- operator delete(void*, const std::nothrow_t&)
1965
- operator delete(void*, std::align_val_t, const std::nothrow_t&)
1966
- ```
1967
-
1968
- ``` cpp
1969
- operator new[](std::size_t)
1970
- operator new[](std::size_t, std::align_val_t)
1971
- operator new[](std::size_t, const std::nothrow_t&)
1972
- operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
1973
- ```
1974
-
1975
- ``` cpp
1976
- operator delete[](void*)
1977
- operator delete[](void*, std::size_t)
1978
- operator delete[](void*, std::align_val_t)
1979
- operator delete[](void*, std::size_t, std::align_val_t)
1980
- operator delete[](void*, const std::nothrow_t&)
1981
- operator delete[](void*, std::align_val_t, const std::nothrow_t&)
1982
- ```
1983
-
1984
- The program’s definitions are used instead of the default versions
1985
- supplied by the implementation [[new.delete]]. Such replacement occurs
1986
- prior to program startup [[basic.def.odr]], [[basic.start]]. The
1987
- program’s declarations shall not be specified as `inline`. No diagnostic
1988
- is required.
1989
 
1990
  #### Handler functions <a id="handler.functions">[[handler.functions]]</a>
1991
 
1992
  The C++ standard library provides a default version of the following
1993
  handler function [[support]]:
@@ -2008,14 +2115,14 @@ A C++ program can get a pointer to the current handler function by
2008
  calling the following functions:
2009
 
2010
  - `get_new_handler`
2011
  - `get_terminate`
2012
 
2013
- Calling the `set_*` and `get_*` functions shall not incur a data race. A
2014
- call to any of the `set_*` functions shall synchronize with subsequent
2015
- calls to the same `set_*` function and to the corresponding `get_*`
2016
- function.
2017
 
2018
  #### Other functions <a id="res.on.functions">[[res.on.functions]]</a>
2019
 
2020
  In certain cases (replacement functions, handler functions, operations
2021
  on types used to instantiate standard library template components), the
@@ -2023,13 +2130,13 @@ C++ standard library depends on components supplied by a C++ program. If
2023
  these components do not meet their requirements, this document places no
2024
  requirements on the implementation.
2025
 
2026
  In particular, the behavior is undefined in the following cases:
2027
 
2028
- - For replacement functions [[new.delete]], if the installed replacement
2029
- function does not implement the semantics of the applicable *Required
2030
- behavior:* paragraph.
2031
  - For handler functions [[new.handler]], [[terminate.handler]], if the
2032
  installed handler function does not implement the semantics of the
2033
  applicable *Required behavior:* paragraph.
2034
  - For types used as template arguments when instantiating a template
2035
  component, if the operations on the type do not implement the
@@ -2057,11 +2164,11 @@ the C++ standard library, unless explicitly stated otherwise.
2057
  address computations and accesses to objects (that would be valid if
2058
  the pointer did point to the first element of such an array) are in
2059
  fact valid.
2060
  - If a function argument is bound to an rvalue reference parameter, the
2061
  implementation may assume that this parameter is a unique reference to
2062
- this argument, except that the argument passed to a move-assignment
2063
  operator may be a reference to `*this` [[lib.types.movedfrom]].
2064
  \[*Note 1*: If the type of a parameter is a forwarding reference
2065
  [[temp.deduct.call]] that is deduced to an lvalue reference type, then
2066
  the argument is not bound to an rvalue reference. — *end note*]
2067
  \[*Note 2*: If a program casts an lvalue to an xvalue while passing
@@ -2110,16 +2217,21 @@ program is ill-formed, no diagnostic required.
2110
  #### Overview <a id="conforming.overview">[[conforming.overview]]</a>
2111
 
2112
  Subclause [[conforming]] describes the constraints upon, and latitude
2113
  of, implementations of the C++ standard library.
2114
 
2115
- An implementation’s use of headers is discussed in  [[res.on.headers]],
2116
- its use of macros in  [[res.on.macro.definitions]], non-member functions
2117
- in  [[global.functions]], member functions in  [[member.functions]],
2118
- data race avoidance in  [[res.on.data.races]], access specifiers in 
2119
- [[protection.within.classes]], class derivation in  [[derivation]], and
2120
- exceptions in  [[res.on.exception.handling]].
 
 
 
 
 
2121
 
2122
  #### Headers <a id="res.on.headers">[[res.on.headers]]</a>
2123
 
2124
  A C++ header may include other C++ headers. A C++ header shall provide
2125
  the declarations and definitions that appear in its synopsis. A C++
@@ -2149,11 +2261,11 @@ stated otherwise.
2149
 
2150
  It is unspecified whether any non-member functions in the C++ standard
2151
  library are defined as inline [[dcl.inline]].
2152
 
2153
  A call to a non-member function signature described in [[support]]
2154
- through [[thread]] and [[depr]] shall behave as if the implementation
2155
  declared no additional non-member function signatures.[^25]
2156
 
2157
  An implementation shall not declare a non-member function signature with
2158
  additional default arguments.
2159
 
@@ -2201,12 +2313,12 @@ signatures for a member function name. — *end note*]
2201
  Whenever this document specifies a friend declaration of a function or
2202
  function template within a class or class template definition, that
2203
  declaration shall be the only declaration of that function or function
2204
  template provided by an implementation.
2205
 
2206
- [*Note 1*: In particular, an implementation is not allowed to provide
2207
- an additional declaration of that function or function template at
2208
  namespace scope. — *end note*]
2209
 
2210
  [*Note 2*: Such a friend function or function template declaration is
2211
  known as a hidden friend, as it is visible neither to ordinary
2212
  unqualified lookup [[basic.lookup.unqual]] nor to qualified lookup
@@ -2216,12 +2328,12 @@ unqualified lookup [[basic.lookup.unqual]] nor to qualified lookup
2216
 
2217
  This document explicitly requires that certain standard library
2218
  functions are `constexpr` [[dcl.constexpr]]. An implementation shall not
2219
  declare any standard library function signature as `constexpr` except
2220
  for those where it is explicitly required. Within any header that
2221
- provides any non-defining declarations of constexpr functions or
2222
- constructors an implementation shall provide corresponding definitions.
2223
 
2224
  #### Requirements for stable algorithms <a id="algorithm.stable">[[algorithm.stable]]</a>
2225
 
2226
  When the requirements for an algorithm state that it is “stable” without
2227
  further elaboration, it means:
@@ -2286,14 +2398,32 @@ all operations solely within the current thread if those operations have
2286
  effects that are visible [[intro.multithread]] to users.
2287
 
2288
  [*Note 3*: This allows implementations to parallelize operations if
2289
  there are no visible side effects. — *end note*]
2290
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2291
  #### Protection within classes <a id="protection.within.classes">[[protection.within.classes]]</a>
2292
 
2293
  It is unspecified whether any function signature or class described in
2294
- [[support]] through [[thread]] and [[depr]] is a friend of another class
2295
  in the C++ standard library.
2296
 
2297
  #### Derived classes <a id="derivation">[[derivation]]</a>
2298
 
2299
  An implementation may derive any class in the C++ standard library from
@@ -2321,21 +2451,22 @@ types unless otherwise specified.
2321
  #### Restrictions on exception handling <a id="res.on.exception.handling">[[res.on.exception.handling]]</a>
2322
 
2323
  Any of the functions defined in the C++ standard library can report a
2324
  failure by throwing an exception of a type described in its *Throws:*
2325
  paragraph, or of a type derived from a type named in the *Throws:*
2326
- paragraph that would be caught by an exception handler for the base
2327
- type.
2328
 
2329
  Functions from the C standard library shall not throw exceptions [^26]
2330
 
2331
  except when such a function calls a program-supplied function that
2332
  throws an exception.[^27]
2333
 
2334
  Destructor operations defined in the C++ standard library shall not
2335
  throw exceptions. Every destructor in the C++ standard library shall
2336
- behave as if it had a non-throwing exception specification.
 
2337
 
2338
  Functions defined in the C++ standard library that do not have a
2339
  *Throws:* paragraph but do have a potentially-throwing exception
2340
  specification may throw *implementation-defined* exceptions.[^28]
2341
 
@@ -2344,15 +2475,22 @@ derived from the standard exception classes
2344
  [[bad.alloc]], [[support.exception]], [[std.exceptions]].
2345
 
2346
  An implementation may strengthen the exception specification for a
2347
  non-virtual function by adding a non-throwing exception specification.
2348
 
 
 
 
 
 
 
 
2349
  #### Value of error codes <a id="value.error.codes">[[value.error.codes]]</a>
2350
 
2351
  Certain functions in the C++ standard library report errors via a
2352
- `std::error_code` [[syserr.errcode.overview]] object. That object’s
2353
- `category()` member shall return `std::system_category()` for errors
2354
  originating from the operating system, or a reference to an
2355
  *implementation-defined* `error_category` object for errors originating
2356
  elsewhere. The implementation shall define the possible values of
2357
  `value()` for each of these error categories.
2358
 
@@ -2368,56 +2506,65 @@ associated values. — *end example*]
2368
  #### Moved-from state of library types <a id="lib.types.movedfrom">[[lib.types.movedfrom]]</a>
2369
 
2370
  Objects of types defined in the C++ standard library may be moved from
2371
  [[class.copy.ctor]]. Move operations may be explicitly specified or
2372
  implicitly generated. Unless otherwise specified, such moved-from
2373
- objects shall be placed in a valid but unspecified state.
 
2374
 
2375
  An object of a type defined in the C++ standard library may be
2376
  move-assigned [[class.copy.assign]] to itself. Unless otherwise
2377
  specified, such an assignment places the object in a valid but
2378
  unspecified state.
2379
 
2380
  <!-- Link reference definitions -->
2381
  [alg.c.library]: algorithms.md#alg.c.library
 
2382
  [alg.sorting]: algorithms.md#alg.sorting
2383
  [algorithm.stable]: #algorithm.stable
2384
  [algorithms]: algorithms.md#algorithms
2385
  [algorithms.requirements]: algorithms.md#algorithms.requirements
2386
  [alloc.errors]: support.md#alloc.errors
2387
  [allocator.requirements]: #allocator.requirements
2388
  [allocator.requirements.completeness]: #allocator.requirements.completeness
2389
  [allocator.requirements.general]: #allocator.requirements.general
2390
  [allocator.traits]: mem.md#allocator.traits
2391
  [alt.headers]: #alt.headers
 
2392
  [array.creation]: containers.md#array.creation
2393
  [atomics]: thread.md#atomics
2394
  [bad.alloc]: support.md#bad.alloc
 
 
2395
  [basic.def.odr]: basic.md#basic.def.odr
2396
  [basic.fundamental]: basic.md#basic.fundamental
 
2397
  [basic.life]: basic.md#basic.life
2398
  [basic.link]: basic.md#basic.link
2399
  [basic.lookup.argdep]: basic.md#basic.lookup.argdep
2400
  [basic.lookup.qual]: basic.md#basic.lookup.qual
2401
  [basic.lookup.unqual]: basic.md#basic.lookup.unqual
2402
  [basic.scope.namespace]: basic.md#basic.scope.namespace
2403
- [basic.start]: basic.md#basic.start
2404
  [basic.stc.dynamic]: basic.md#basic.stc.dynamic
2405
  [bit]: utilities.md#bit
2406
  [bitmask.types]: #bitmask.types
2407
  [byte.strings]: #byte.strings
2408
  [c.annex.k.names]: #c.annex.k.names
 
 
2409
  [cassert.syn]: diagnostics.md#cassert.syn
2410
  [cerrno.syn]: diagnostics.md#cerrno.syn
2411
  [character.seq]: #character.seq
2412
  [character.seq.general]: #character.seq.general
 
2413
  [class.copy.assign]: class.md#class.copy.assign
2414
  [class.copy.ctor]: class.md#class.copy.ctor
2415
  [class.dtor]: class.md#class.dtor
2416
  [class.mem]: class.md#class.mem
 
2417
  [class.virtual]: class.md#class.virtual
2418
- [clocale.syn]: localization.md#clocale.syn
2419
  [cmp]: support.md#cmp
2420
  [compliance]: #compliance
2421
  [concept.destructible]: concepts.md#concept.destructible
2422
  [concept.invocable]: concepts.md#concept.invocable
2423
  [concept.totallyordered]: concepts.md#concept.totallyordered
@@ -2435,40 +2582,51 @@ unspecified state.
2435
  [conv]: expr.md#conv
2436
  [conv.func]: expr.md#conv.func
2437
  [conventions]: #conventions
2438
  [conventions.general]: #conventions.general
2439
  [cpp.include]: cpp.md#cpp.include
2440
- [cpp.replace]: cpp.md#cpp.replace
2441
  [cpp17.copyassignable]: #cpp17.copyassignable
2442
  [cpp17.copyconstructible]: #cpp17.copyconstructible
2443
  [cpp17.destructible]: #cpp17.destructible
2444
  [cpp17.hash]: #cpp17.hash
2445
  [cpp17.moveassignable]: #cpp17.moveassignable
2446
  [cpp17.nullablepointer]: #cpp17.nullablepointer
2447
  [cstdarg.syn]: support.md#cstdarg.syn
2448
  [cstddef.syn]: support.md#cstddef.syn
2449
  [cstdint.syn]: support.md#cstdint.syn
 
2450
  [customization.point.object]: #customization.point.object
2451
  [dcl.array]: dcl.md#dcl.array
2452
- [dcl.attr]: dcl.md#dcl.attr
2453
  [dcl.constexpr]: dcl.md#dcl.constexpr
 
 
2454
  [dcl.fct.default]: dcl.md#dcl.fct.default
2455
  [dcl.init]: dcl.md#dcl.init
2456
  [dcl.inline]: dcl.md#dcl.inline
2457
  [dcl.link]: dcl.md#dcl.link
2458
  [dcl.pre]: dcl.md#dcl.pre
2459
  [dcl.typedef]: dcl.md#dcl.typedef
 
 
2460
  [defns.nonconst.libcall]: intro.md#defns.nonconst.libcall
 
2461
  [depr]: future.md#depr
2462
  [derivation]: #derivation
2463
  [derived.classes]: #derived.classes
2464
  [description]: #description
2465
  [description.general]: #description.general
2466
  [diagnostics]: diagnostics.md#diagnostics
2467
  [enumerated.types]: #enumerated.types
 
2468
  [except]: except.md#except
 
 
 
 
 
2469
  [expos.only.entity]: #expos.only.entity
 
2470
  [expr.delete]: expr.md#expr.delete
2471
  [expr.new]: expr.md#expr.new
2472
  [expr.unary.op]: expr.md#expr.unary.op
2473
  [extern.names]: #extern.names
2474
  [extern.types]: #extern.types
@@ -2481,28 +2639,29 @@ unspecified state.
2481
  [headers]: #headers
2482
  [headers.cpp]: #headers.cpp
2483
  [headers.cpp.c]: #headers.cpp.c
2484
  [headers.cpp.fs]: #headers.cpp.fs
2485
  [hidden.friends]: #hidden.friends
 
2486
  [input.output]: input.md#input.output
2487
  [intro.compliance]: intro.md#intro.compliance
2488
  [intro.multithread]: basic.md#intro.multithread
 
2489
  [intro.refs]: intro.md#intro.refs
2490
  [iterator.requirements]: iterators.md#iterator.requirements
2491
  [iterators]: iterators.md#iterators
2492
  [lex.charset]: lex.md#lex.charset
2493
  [lex.name]: lex.md#lex.name
2494
- [lex.name.special]: #lex.name.special
2495
  [lex.phases]: lex.md#lex.phases
2496
  [lex.separate]: lex.md#lex.separate
2497
  [lib.types.movedfrom]: #lib.types.movedfrom
2498
  [library]: #library
2499
  [library.c]: #library.c
2500
  [library.categories]: #library.categories
 
2501
  [library.general]: #library.general
2502
- [locales]: localization.md#locales
2503
- [localization]: localization.md#localization
2504
  [macro.names]: #macro.names
2505
  [mem]: mem.md#mem
2506
  [member.functions]: #member.functions
2507
  [memory]: mem.md#memory
2508
  [meta]: meta.md#meta
@@ -2512,32 +2671,34 @@ unspecified state.
2512
  [namespace.def]: dcl.md#namespace.def
2513
  [namespace.future]: #namespace.future
2514
  [namespace.posix]: #namespace.posix
2515
  [namespace.std]: #namespace.std
2516
  [namespace.udecl]: dcl.md#namespace.udecl
2517
- [new.delete]: support.md#new.delete
2518
  [new.handler]: support.md#new.handler
2519
- [new.syn]: support.md#new.syn
2520
  [nullablepointer.requirements]: #nullablepointer.requirements
2521
  [numeric.requirements]: numerics.md#numeric.requirements
2522
  [numerics]: numerics.md#numerics
 
2523
  [objects.within.classes]: #objects.within.classes
 
2524
  [organization]: #organization
2525
  [organization.general]: #organization.general
2526
  [ostream.iterator.ops]: iterators.md#ostream.iterator.ops
2527
  [over.literal]: over.md#over.literal
2528
  [over.match]: over.md#over.match
2529
  [over.match.oper]: over.md#over.match.oper
2530
  [protection.within.classes]: #protection.within.classes
 
2531
  [random.access.iterators]: iterators.md#random.access.iterators
2532
  [ranges]: ranges.md#ranges
2533
  [ratio]: meta.md#ratio
2534
- [re]: re.md#re
2535
  [reentrancy]: #reentrancy
2536
  [replacement.functions]: #replacement.functions
2537
  [requirements]: #requirements
2538
  [requirements.general]: #requirements.general
 
2539
  [res.on.arguments]: #res.on.arguments
2540
  [res.on.data.races]: #res.on.data.races
2541
  [res.on.exception.handling]: #res.on.exception.handling
2542
  [res.on.functions]: #res.on.functions
2543
  [res.on.headers]: #res.on.headers
@@ -2547,31 +2708,34 @@ unspecified state.
2547
  [reserved.names]: #reserved.names
2548
  [reserved.names.general]: #reserved.names.general
2549
  [specialized.addressof]: mem.md#specialized.addressof
2550
  [std.exceptions]: diagnostics.md#std.exceptions
2551
  [std.modules]: #std.modules
 
2552
  [stmt.return]: stmt.md#stmt.return
2553
  [stream.types]: input.md#stream.types
 
 
2554
  [strings]: strings.md#strings
2555
  [structure]: #structure
2556
  [structure.elements]: #structure.elements
2557
  [structure.requirements]: #structure.requirements
2558
  [structure.see.also]: #structure.see.also
2559
  [structure.specifications]: #structure.specifications
2560
  [structure.summary]: #structure.summary
2561
  [support]: support.md#support
2562
  [support.c.headers]: support.md#support.c.headers
2563
  [support.c.headers.other]: support.md#support.c.headers.other
 
2564
  [support.coroutine]: support.md#support.coroutine
2565
  [support.dynamic]: support.md#support.dynamic
2566
  [support.exception]: support.md#support.exception
2567
  [support.initlist]: support.md#support.initlist
2568
  [support.limits]: support.md#support.limits
2569
  [support.rtti]: support.md#support.rtti
2570
  [support.runtime]: support.md#support.runtime
2571
  [support.srcloc]: support.md#support.srcloc
2572
- [support.start.term]: support.md#support.start.term
2573
  [support.types]: support.md#support.types
2574
  [swappable.requirements]: #swappable.requirements
2575
  [syserr]: diagnostics.md#syserr
2576
  [syserr.errcode.overview]: diagnostics.md#syserr.errcode.overview
2577
  [tab:cpp17.destructible]: #tab:cpp17.destructible
@@ -2581,11 +2745,13 @@ unspecified state.
2581
  [temp.constr.decl]: temp.md#temp.constr.decl
2582
  [temp.deduct.call]: temp.md#temp.deduct.call
2583
  [template.bitset]: utilities.md#template.bitset
2584
  [term.incomplete.type]: basic.md#term.incomplete.type
2585
  [term.object.type]: basic.md#term.object.type
 
2586
  [terminate.handler]: support.md#terminate.handler
 
2587
  [thread]: thread.md#thread
2588
  [time]: time.md#time
2589
  [tuple]: utilities.md#tuple
2590
  [type.descriptions]: #type.descriptions
2591
  [type.descriptions.general]: #type.descriptions.general
@@ -2599,13 +2765,20 @@ unspecified state.
2599
  [utility]: utilities.md#utility
2600
  [utility.arg.requirements]: #utility.arg.requirements
2601
  [utility.requirements]: #utility.requirements
2602
  [utility.requirements.general]: #utility.requirements.general
2603
  [value.error.codes]: #value.error.codes
 
 
 
2604
  [zombie.names]: #zombie.names
 
 
 
 
2605
 
2606
- [^1]: See also ISO/IEC 9899:2018 section 7.6.
2607
 
2608
  [^2]: To save space, items that do not apply to a Clause are omitted.
2609
  For example, if a Clause does not specify any requirements, there
2610
  will be no “Requirements” subclause.
2611
 
@@ -2674,11 +2847,12 @@ unspecified state.
2674
 
2675
  [^19]: This is the same as the C standard library.
2676
 
2677
  [^20]: The only reliable way to declare an object or function signature
2678
  from the C standard library is by including the header that declares
2679
- it, notwithstanding the latitude granted in 7.1.4 of the C Standard.
 
2680
 
2681
  [^21]: Any library code that instantiates other library templates must
2682
  be prepared to work adequately with any user-supplied specialization
2683
  that meets the minimum requirements of this document.
2684
 
@@ -2697,12 +2871,12 @@ unspecified state.
2697
 
2698
  [^25]: A valid C++ program always calls the expected library non-member
2699
  function. An implementation can also define additional non-member
2700
  functions that would otherwise not be called by a valid C++ program.
2701
 
2702
- [^26]: That is, the C library functions can all be treated as if they
2703
- are marked `noexcept`. This allows implementations to make
2704
  performance optimizations based on the absence of exceptions at
2705
  runtime.
2706
 
2707
  [^27]: The functions `qsort()` and `bsearch()` [[alg.c.library]] meet
2708
  this condition.
 
6
  well-formed C++ program makes use of the library, and how a conforming
7
  implementation may provide the entities in the library.
8
 
9
  The following subclauses describe the method of description
10
  [[description]] and organization [[organization]] of the library.
11
+ [[requirements]], [[support]] through [[exec]], and [[depr]] specify the
12
+ contents of the library, as well as library requirements and constraints
13
+ on both well-formed C++ programs and conforming implementations.
 
14
 
15
  Detailed specifications for each of the components in the library are in
16
+ [[support]]– [[exec]], as shown in [[library.categories]].
17
 
18
  **Table: Library categories** <a id="library.categories">[library.categories]</a>
19
 
20
  | Clause | Category |
21
  | ---------------- | --------------------------- |
 
23
  | [[concepts]] | Concepts library |
24
  | [[diagnostics]] | Diagnostics library |
25
  | [[mem]] | Memory management library |
26
  | [[meta]] | Metaprogramming library |
27
  | [[utilities]] | General utilities library |
 
28
  | [[containers]] | Containers library |
29
  | [[iterators]] | Iterators library |
30
  | [[ranges]] | Ranges library |
31
  | [[algorithms]] | Algorithms library |
32
+ | [[strings]] | Strings library |
33
+ | [[text]] | Text processing library |
34
  | [[numerics]] | Numerics library |
35
  | [[time]] | Time library |
 
36
  | [[input.output]] | Input/output library |
 
37
  | [[thread]] | Concurrency support library |
38
+ | [[exec]] | Execution control library |
39
 
40
 
41
+ The operating system interface described in IEEE 1003.1-2017 (POSIX) is
42
+ hereinafter called *POSIX*.
43
+
44
  The language support library [[support]] provides components that are
45
  required by certain parts of the C++ language, such as memory allocation
46
  [[expr.new]], [[expr.delete]] and exception processing [[except]].
47
 
48
  The concepts library [[concepts]] describes library components that C++
 
63
  The general utilities library [[utilities]] includes components used by
64
  other library elements, such as a predefined storage allocator for
65
  dynamic storage management [[basic.stc.dynamic]], and components used as
66
  infrastructure in C++ programs, such as tuples and function wrappers.
67
 
 
 
 
 
 
68
  The containers [[containers]], iterators [[iterators]], ranges
69
  [[ranges]], and algorithms [[algorithms]] libraries provide a C++
70
  program with access to a subset of the most widely used algorithms and
71
  data structures.
72
 
73
+ The strings library [[strings]] provides support for manipulating
74
+ sequences of type `char`, sequences of type `char8_t`, sequences of type
75
+ `char16_t`, sequences of type `char32_t`, sequences of type `wchar_t`,
76
+ and sequences of any other character-like type.
77
+
78
+ The text processing library [[text]] provides support for text
79
+ processing, including formatting, internationalization support and
80
+ regular expression matching and searching.
81
+
82
  The numerics library [[numerics]] provides numeric algorithms and
83
  complex number components that extend support for numeric processing.
84
  The `valarray` component provides support for *n*-at-a-time processing,
85
  potentially implemented as parallel operations on platforms that support
86
  such processing. The random number component provides facilities for
87
  generating pseudo-random numbers.
88
 
89
  The time library [[time]] provides generally useful time utilities.
90
 
 
 
 
91
  The input/output library [[input.output]] provides the `iostream`
92
  components that are the primary mechanism for C++ program input and
93
  output. They can be used with other elements of the library,
94
  particularly strings, locales, and iterators.
95
 
 
 
 
96
  The concurrency support library [[thread]] provides components to create
97
  and manage threads, including atomic operations, mutual exclusion, and
98
  interthread communication.
99
 
100
+ The execution control library [[exec]] provides components supporting
101
+ execution of function objects.
102
+
103
  ## The C standard library <a id="library.c">[[library.c]]</a>
104
 
105
  The C++ standard library also makes available the facilities of the C
106
  standard library, suitably adjusted to ensure static type safety.
107
 
108
  The descriptions of many library functions rely on the C standard
109
  library for the semantics of those functions. In some cases, the
110
  signatures specified in this document may be different from the
111
  signatures in the C standard library, and additional overloads may be
112
  declared in this document, but the behavior and the preconditions
113
+ (including any preconditions implied by the use of a C `restrict`
114
  qualifier) are the same unless otherwise stated.
115
 
116
  A call to a C standard library function is a non-constant library call
117
  [[defns.nonconst.libcall]] if it raises a floating-point exception other
118
  than `FE_INEXACT`. The semantics of a call to a C standard library
119
  function evaluated as a core constant expression are those specified in
120
+ ISO/IEC 9899:2018 (C), Annex F[^1]
121
 
122
  to the extent applicable to the floating-point types
123
  [[basic.fundamental]] that are parameter types of the called function.
124
 
125
+ [*Note 1*: ISO/IEC 9899:2018 (C), Annex F specifies the conditions
126
+ under which floating-point exceptions are raised and the behavior when
127
+ NaNs and/or infinities are passed as arguments. — *end note*]
128
 
129
  [*Note 2*: Equivalently, a call to a C standard library function is a
130
  non-constant library call if `errno` is set when
131
  `math_errhandling & MATH_ERRNO` is `true`. — *end note*]
132
 
 
134
 
135
  ### General <a id="description.general">[[description.general]]</a>
136
 
137
  Subclause [[description]] describes the conventions used to specify the
138
  C++ standard library. [[structure]] describes the structure of
139
+ [[support]] through [[exec]] and [[depr]]. [[conventions]] describes
140
  other editorial conventions.
141
 
142
  ### Structure of each clause <a id="structure">[[structure]]</a>
143
 
144
  #### Elements <a id="structure.elements">[[structure.elements]]</a>
 
256
  overload resolution [[over.match]]. \[*Note 1*: Failure to meet such a
257
  condition results in the function’s silent
258
  non-viability. — *end note*] \[*Example 1*: An implementation can
259
  express such a condition via a *constraint-expression*
260
  [[temp.constr.decl]]. — *end example*]
261
+
262
  - *Mandates:* the conditions that, if not met, render the program
263
  ill-formed. \[*Example 2*: An implementation can express such a
264
  condition via the *constant-expression* in a
265
  *static_assert-declaration* [[dcl.pre]]. If the diagnostic is to be
266
  emitted only after the function has been selected by overload
267
  resolution, an implementation can express such a condition via a
268
  *constraint-expression* [[temp.constr.decl]] and also define the
269
  function as deleted. — *end example*]
270
+
271
+ - the conditions that are required for a call to the function to be a
272
+ constant subexpression [[defns.const.subexpr]].
273
+
274
+ - *Preconditions:* conditions that the function assumes to hold whenever
275
+ it is called; violation of any preconditions results in undefined
276
+ behavior. \[*Example 3*: An implementation can express some such
277
+ conditions via the use of a contract assertion, such as a precondition
278
+ assertion [[dcl.contract.func]]. — *end example*]
279
+
280
+ - conditions that the function assumes to hold whenever it is called.
281
+ - When invoking the function in a hardened implementation, prior to
282
+ any other observable side effects of the function, one or more
283
+ contract assertions whose predicates are as described in the
284
+ hardened precondition are evaluated with a checking semantic
285
+ [[basic.contract.eval]]. If any of these assertions is evaluated
286
+ with a non-terminating semantic and the contract-violation handler
287
+ returns, the program has undefined behavior.
288
+ - When invoking the function in a non-hardened implementation, if any
289
+ hardened precondition is violated, the program has undefined
290
+ behavior.
291
+
292
  - *Effects:* the actions performed by the function.
293
+
294
  - *Synchronization:* the synchronization operations
295
  [[intro.multithread]] applicable to the function.
296
+
297
  - *Ensures:* the conditions (sometimes termed observable results)
298
+ established by the function. \[*Example 4*: An implementation can
299
+ express some such conditions via the use of a contract assertion, such
300
+ as a postcondition assertion [[dcl.contract.func]]. — *end example*]
301
+
302
  - *Result:* for a *typename-specifier*, a description of the named type;
303
+ for an *expression*, a description of the type and value category of
304
+ the expression; the expression is an lvalue if the type is an lvalue
305
+ reference type, an xvalue if the type is an rvalue reference type, and
306
+ a prvalue otherwise.
307
+
308
  - *Returns:* a description of the value(s) returned by the function.
309
+
310
  - *Throws:* any exceptions thrown by the function, and the conditions
311
  that would cause the exception.
312
+
313
  - *Complexity:* the time and/or space complexity of the function.
314
+
315
  - *Remarks:* additional semantic constraints on the function.
316
+
317
  - *Error conditions:* the error conditions for error codes reported by
318
  the function.
319
 
320
  Whenever the *Effects* element specifies that the semantics of some
321
  function `F` are *Equivalent to* some code sequence, then the various
322
  elements are interpreted as follows. If `F`’s semantics specifies any
323
  *Constraints* or *Mandates* elements, then those requirements are
324
  logically imposed prior to the *equivalent-to* semantics. Next, the
325
  semantics of the code sequence are determined by the *Constraints*,
326
+ *Mandates*, *Constant When*, *Preconditions*, *Hardened preconditions*,
327
+ *Effects*, *Synchronization*, *Postconditions*, *Returns*, *Throws*,
328
+ *Complexity*, *Remarks*, and *Error conditions* specified for the
329
+ function invocations contained in the code sequence. The value returned
330
+ from `F` is specified by `F`’s *Returns* element, or if `F` has no
331
+ *Returns* element, a non-`void` return from `F` is specified by the
332
+ `return` statements [[stmt.return]] in the code sequence. If `F`’s
333
+ semantics contains a *Throws*, *Postconditions*, or *Complexity*
334
+ element, then that supersedes any occurrences of that element in the
335
+ code sequence.
336
 
337
  For non-reserved replacement and handler functions, [[support]]
338
  specifies two behaviors for the functions in question: their required
339
  and default behavior. The *default behavior* describes a function
340
  definition provided by the implementation. The *required behavior*
 
368
  are for describing implementation-defined types [[type.descriptions]],
369
  and member functions [[functions.within.classes]].
370
 
371
  #### Exposition-only entities, etc. <a id="expos.only.entity">[[expos.only.entity]]</a>
372
 
373
+ Several entities defined in [[support]] through [[exec]] and [[depr]]
374
+ are only defined for the purpose of exposition. The declaration of such
375
+ an entity is followed by a comment ending in *exposition only*.
 
376
 
377
  The following are defined for exposition only to aid in the
378
  specification of the library:
379
 
380
  ``` cpp
381
  namespace std {
382
  template<class T>
383
  requires convertible_to<T, decay_t<T>>
384
+ constexpr decay_t<T> decay-copy(T&& v) // exposition only
385
+ noexcept(is_nothrow_convertible_v<T, decay_t<T>>)
386
  { return std::forward<T>(v); }
387
 
388
+ constexpr auto synth-three-way = // exposition only
389
  []<class T, class U>(const T& t, const U& u)
390
  requires requires {
391
  { t < u } -> boolean-testable;
392
  { u < t } -> boolean-testable;
393
  }
 
400
  return weak_ordering::equivalent;
401
  }
402
  };
403
 
404
  template<class T, class U = T>
405
+ using synth-three-way-result = // exposition only
406
+ decltype(synth-three-way(declval<T&>(), declval<U&>()));
407
  }
408
  ```
409
 
410
+ An object `dst` is said to be *decay-copied from* a subexpression `src`
411
+ if the type of `dst` is
412
+
413
+ ``` cpp
414
+ decay_t<decltype((src))>
415
+ ```
416
+
417
+ and `dst` is copy-initialized from `src`.
418
+
419
  #### Type descriptions <a id="type.descriptions">[[type.descriptions]]</a>
420
 
421
  ##### General <a id="type.descriptions.general">[[type.descriptions.general]]</a>
422
 
423
  The Requirements subclauses may describe names that are used to specify
 
452
  Here, the names `C₀`, `C₁`, etc. represent *enumerated elements* for
453
  this particular enumerated type. All such elements have distinct values.
454
 
455
  ##### Bitmask types <a id="bitmask.types">[[bitmask.types]]</a>
456
 
457
+ Several types defined in [[support]] through [[exec]] and [[depr]] are
458
  *bitmask types*. Each bitmask type can be implemented as an enumerated
459
  type that overloads certain operators, as an integer type, or as a
460
  `bitset` [[template.bitset]].
461
 
462
  The bitmask type `bitmask` can be written:
 
538
  basic character set.
539
  - The *decimal-point character* is the locale-specific (single-byte)
540
  character used by functions that convert between a (single-byte)
541
  character sequence and a value of one of the floating-point types. It
542
  is used in the character sequence to denote the beginning of a
543
+ fractional part. It is represented in [[support]] through [[exec]] and
544
+ [[depr]] by a period, `'.'`, which is also its value in the `"C"`
545
  locale.
546
  - A *character sequence* is an array object [[dcl.array]] `A` that can
547
  be declared as `T A[N]`, where `T` is any of the types `char`,
548
  `unsigned char`, or `signed char` [[basic.fundamental]], optionally
549
  qualified by any combination of `const` or `volatile`. The initial
550
  elements of the array have defined contents up to and including an
551
  element determined by some predicate. A character sequence can be
552
  designated by a pointer value `S` that points to its first element.
553
+ - Let *`STATICALLY-WIDEN`*`<charT>("...")` be `"..."` if `charT` is
554
+ `char` and `L"..."` if `charT` is `wchar_t`.
555
 
556
  ###### Byte strings <a id="byte.strings">[[byte.strings]]</a>
557
 
558
  A *null-terminated byte string*, or NTBS, is a character sequence whose
559
  highest-addressed element with defined content has the value zero (the
 
611
  - `p(args...)`
612
  - `as_const(p)(args...)`
613
  - `std::move(p)(args...)`
614
  - `std::move(as_const(p))(args...)`
615
 
616
+ #### Algorithm function objects <a id="alg.func.obj">[[alg.func.obj]]</a>
617
+
618
+ An *algorithm function object* is a customization point object
619
+ [[customization.point.object]] that is specified as one or more
620
+ overloaded function templates. The name of these function templates
621
+ designates the corresponding algorithm function object.
622
+
623
+ For an algorithm function object `o`, let S be the corresponding set of
624
+ function templates. Then for any sequence of arguments `args` …,
625
+ `o(args` … `)` is expression-equivalent to `s(args` … `)`, where the
626
+ result of name lookup for `s` is the overload set S.
627
+
628
+ [*Note 1*:
629
+
630
+ Algorithm function objects are not found by argument-dependent name
631
+ lookup [[basic.lookup.argdep]]. When found by unqualified name lookup
632
+ [[basic.lookup.unqual]] for the *postfix-expression* in a function call
633
+ [[expr.call]], they inhibit argument-dependent name lookup.
634
+
635
+ [*Example 1*:
636
+
637
+ ``` cpp
638
+ void foo() {
639
+ using namespace std::ranges;
640
+ std::vector<int> vec{1,2,3};
641
+ find(begin(vec), end(vec), 2); // #1
642
+ }
643
+ ```
644
+
645
+ The function call expression at \#1 invokes `std::ranges::find`, not
646
+ `std::find`.
647
+
648
+ — *end example*]
649
+
650
+ — *end note*]
651
 
652
  #### Functions within classes <a id="functions.within.classes">[[functions.within.classes]]</a>
653
 
654
+ For the sake of exposition, [[support]] through [[exec]] and [[depr]] do
655
+ not describe copy/move constructors, assignment operators, or
656
  (non-virtual) destructors with the same apparent semantics as those that
657
  can be generated by default
658
  [[class.copy.ctor]], [[class.copy.assign]], [[class.dtor]]. It is
659
  unspecified whether the implementation provides explicit definitions for
660
  such member function signatures, or for virtual destructors that can be
661
  generated by default.
662
 
663
  #### Private members <a id="objects.within.classes">[[objects.within.classes]]</a>
664
 
665
+ [[support]] through [[exec]] and [[depr]] do not specify the
666
  representation of classes, and intentionally omit specification of class
667
  members [[class.mem]]. An implementation may define static or non-static
668
  class members, or both, as needed to implement the semantics of the
669
+ member functions specified in [[support]] through [[exec]] and [[depr]].
 
670
 
671
  For the sake of exposition, some subclauses provide representative
672
  declarations, and semantic requirements, for private members of classes
673
  that meet the external specifications of the classes. The declarations
674
  for such members are followed by a comment that ends with *exposition
 
681
  An implementation may use any technique that provides equivalent
682
  observable behavior.
683
 
684
  #### Freestanding items <a id="freestanding.item">[[freestanding.item]]</a>
685
 
686
+ A *freestanding item* is a declaration, entity, or macro that is
687
+ required to be present in a freestanding implementation and a hosted
688
+ implementation.
689
 
690
  Unless otherwise specified, the requirements on freestanding items for a
691
  freestanding implementation are the same as the corresponding
692
  requirements for a hosted implementation, except that not all of the
693
+ members of those items are required to be present.
694
 
695
+ Function declarations and function template declarations followed by a
696
+ comment that include *freestanding-deleted* are *freestanding deleted
697
+ functions*. On freestanding implementations, it is
698
+ *implementation-defined* whether each entity introduced by a
699
+ freestanding deleted function is a deleted function
700
+ [[dcl.fct.def.delete]] or whether the requirements are the same as the
701
+ corresponding requirements for a hosted implementation.
702
 
703
+ [*Note 1*: Deleted definitions reduce the chance of overload resolution
704
+ silently changing when migrating from a freestanding implementation to a
705
+ hosted implementation. — *end note*]
706
 
707
+ [*Example 1*:
 
 
708
 
709
+ ``` cpp
710
+ double abs(double j); // freestanding-deleted
711
+ ```
712
+
713
+ — *end example*]
714
+
715
+ A declaration in a synopsis is a freestanding item if
716
+
717
+ - it is followed by a comment that includes *freestanding*,
718
+ - it is followed by a comment that includes *freestanding-deleted*, or
719
+ - the header synopsis begins with a comment that includes *freestanding*
720
+ and the declaration is not followed by a comment that includes
721
+ *hosted*. \[*Note 2*: Declarations followed by *hosted* in
722
+ freestanding headers are not freestanding items. As a result, looking
723
+ up the name of such functions can vary between hosted and freestanding
724
+ implementations. — *end note*]
725
+
726
+ [*Example 2*:
727
+
728
+ ``` cpp
729
+ // all freestanding
730
+ namespace std {
731
+ ```
732
+
733
+ — *end example*]
734
+
735
+ An entity or deduction guide is a freestanding item if its introducing
736
+ declaration is not followed by a comment that includes *hosted*, and is:
737
 
738
  - introduced by a declaration that is a freestanding item,
739
+ - a member of a freestanding item other than a namespace,
740
+ - an enumerator of a freestanding item,
741
+ - a deduction guide of a freestanding item,
742
  - an enclosing namespace of a freestanding item,
743
  - a friend of a freestanding item,
744
+ - denoted by a type alias that is a freestanding item, or
745
  - denoted by an alias template that is a freestanding item.
746
 
747
  A macro is a freestanding item if it is defined in a header synopsis and
748
 
749
  - the definition is followed by a comment that includes *freestanding*,
750
  or
751
+ - the header synopsis begins with a comment that includes *freestanding*
752
+ and the definition is not followed by a comment that includes
753
+ *hosted*.
754
 
755
+ [*Example 3*:
756
 
757
  ``` cpp
758
  #define NULL see below // freestanding
759
  ```
760
 
761
  — *end example*]
762
 
763
+ [*Note 3*: Freestanding annotations follow some additional exposition
764
+ conventions that do not impose any additional normative requirements.
765
+ Header synopses that begin with a comment containing "all freestanding"
766
+ contain no hosted items and no freestanding deleted functions. Header
767
+ synopses that begin with a comment containing "mostly freestanding"
768
+ contain at least one hosted item or freestanding deleted function.
769
+ Classes and class templates followed by a comment containing "partially
770
+ freestanding" contain at least one hosted item or freestanding deleted
771
+ function. — *end note*]
772
+
773
+ [*Example 4*:
774
 
775
  ``` cpp
776
+ template<class T, size_t N> struct array; // partially freestanding
777
+ template<class T, size_t N>
778
+ struct array {
779
+ constexpr reference operator[](size_type n);
780
+ constexpr const_reference operator[](size_type n) const;
781
+ constexpr reference at(size_type n); // freestanding-deleted
782
+ constexpr const_reference at(size_type n) const; // freestanding-deleted
783
+ };
784
  ```
785
 
786
  — *end example*]
787
 
788
  ## Library-wide requirements <a id="requirements">[[requirements]]</a>
789
 
790
  ### General <a id="requirements.general">[[requirements.general]]</a>
791
 
792
  Subclause [[requirements]] specifies requirements that apply to the
793
+ entire C++ standard library. [[support]] through [[exec]] and [[depr]]
794
  specify the requirements of individual entities within the library.
795
 
796
  Requirements specified in terms of interactions between threads do not
797
  apply to programs having only a single thread of execution.
798
 
 
824
 
825
  It is unspecified whether names declared in a specific namespace are
826
  declared directly in that namespace or in an inline namespace inside
827
  that namespace.[^13]
828
 
829
+ Whenever an unqualified name other than `swap`, `make_error_code`,
830
+ `make_error_condition`, `from_stream`, or `submdspan_mapping` is used in
831
+ the specification of a declaration `D` in [[support]] through [[exec]]
832
+ or [[depr]], its meaning is established as-if by performing unqualified
833
+ name lookup [[basic.lookup.unqual]] in the context of `D`.
834
 
835
  [*Note 1*: Argument-dependent lookup is not performed. — *end note*]
836
 
837
  Similarly, the meaning of a *qualified-id* is established as-if by
838
  performing qualified name lookup [[basic.lookup.qual]] in the context of
 
845
  [*Note 2*: Operators in expressions [[over.match.oper]] are not so
846
  constrained; see [[global.functions]]. — *end note*]
847
 
848
  The meaning of the unqualified name `swap` is established in an overload
849
  resolution context for swappable values [[swappable.requirements]]. The
850
+ meanings of the unqualified names `make_error_code`,
851
+ `make_error_condition`, `from_stream`, and `submdspan_mapping` are
852
+ established as-if by performing argument-dependent lookup
853
+ [[basic.lookup.argdep]].
854
 
855
  #### Headers <a id="headers">[[headers]]</a>
856
 
857
  Each element of the C++ standard library is declared or defined (as
858
  appropriate) in a *header*.[^14]
 
878
  std::vector<int> vi; // OK
879
  ```
880
 
881
  — *end example*]
882
 
883
+ Except as noted in [[library]] through [[exec]] and [[depr]], the
884
  contents of each header `cname` is the same as that of the corresponding
885
  header `name.h` as specified in the C standard library [[intro.refs]].
886
  In the C++ standard library, however, the declarations (except for names
887
  which are defined as macros in C) are within namespace scope
888
  [[basic.scope.namespace]] of the namespace `std`. It is unspecified
889
  whether these names (including any overloads added in [[support]]
890
+ through [[exec]] and [[depr]]) are first declared within the global
891
  namespace scope and are then injected into namespace `std` by explicit
892
  *using-declaration*s [[namespace.udecl]].
893
 
894
  Names which are defined as macros in C shall be defined as macros in the
895
  C++ standard library, even if C grants license for implementation as
 
903
  in the C++ standard library.[^16]
904
 
905
  Identifiers that are keywords or operators in C++ shall not be defined
906
  as macros in C++ standard library headers.[^17]
907
 
908
+ Subclause [[support.c.headers]] describes the effects of using the
909
+ `name.h` (C header) form in a C++ program.[^18]
910
 
911
+ ISO/IEC 9899:2018 (C), Annex K describes a large number of functions,
912
+ with associated types and macros, which “promote safer, more secure
913
  programming” than many of the traditional C library functions. The names
914
  of the functions have a suffix of `_s`; most of them provide the same
915
  service as the C library function with the unsuffixed name, but
916
  generally take an additional argument whose value is the size of the
917
  result array. If any C++ header is included, it is
 
932
  for C library facilities ([[headers.cpp.c]]). It additionally exports
933
  declarations in the global namespace for the storage allocation and
934
  deallocation functions that are provided by `<new>`.
935
 
936
  The named module `std.compat` exports the same declarations as the named
937
+ module `std`, and additionally exports
938
+
939
+ - declarations in the global namespace corresponding to the declarations
940
+ in namespace `std` that are provided by the C++ headers for C library
941
+ facilities ([[headers.cpp.c]]), except the explicitly excluded
942
+ declarations described in [[support.c.headers.other]] and
943
+ - declarations provided by the headers `<stdbit.h>` and `<stdckdint.h>`.
944
 
945
  It is unspecified to which module a declaration in the standard library
946
  is attached.
947
 
948
+ [*Note 1*: Conforming implementations ensure that mixing `#include` and
949
+ `import` does not result in conflicting attachments
950
  [[basic.link]]. — *end note*]
951
 
952
  *Recommended practice:* Implementations should ensure such attachments
953
  do not preclude further evolution or decomposition of the standard
954
  library modules.
 
977
  [[headers.cpp.fs]].
978
 
979
  **Table: C++ headers for freestanding implementations** <a id="headers.cpp.fs">[headers.cpp.fs]</a>
980
 
981
  | Subclause | | Header |
982
+ | --------------------- | ----------------------------------------------- | ------------------------------------ |
983
  | [[support.types]] | Common definitions | `<cstddef>` |
984
+ | [[cstdlib.syn]] | C standard library | `<cstdlib>` |
985
+ | [[support.limits]] | Implementation properties | `<cfloat>`, `<climits>`, `<limits>`, |
986
+ | | | `<version>` |
987
  | [[cstdint.syn]] | Integer types | `<cstdint>` |
 
988
  | [[support.dynamic]] | Dynamic memory management | `<new>` |
989
  | [[support.rtti]] | Type identification | `<typeinfo>` |
990
  | [[support.srcloc]] | Source location | `<source_location>` |
991
  | [[support.exception]] | Exception handling | `<exception>` |
992
  | [[support.initlist]] | Initializer lists | `<initializer_list>` |
993
  | [[cmp]] | Comparisons | `<compare>` |
994
+ | [[support.contract]] | Contract-violation handling | `<contracts>` |
995
  | [[support.coroutine]] | Coroutines support | `<coroutine>` |
996
  | [[support.runtime]] | Other runtime support | `<cstdarg>` |
997
  | [[concepts]] | Concepts library | `<concepts>` |
998
+ | [[errno]] | Error numbers | `<cerrno>` |
999
+ | [[syserr]] | System error support | `<system_error>` |
1000
+ | [[debugging]] | Debugging | `<debugging>` |
1001
+ | [[memory]] | Memory | `<memory>` |
1002
  | [[type.traits]] | Type traits | `<type_traits>` |
1003
+ | [[ratio]] | Compile-time rational arithmetic | `<ratio>` |
 
1004
  | [[utility]] | Utility components | `<utility>` |
1005
  | [[tuple]] | Tuples | `<tuple>` |
1006
+ | [[optional]] | Optional objects | `<optional>` |
1007
+ | [[variant]] | Variants | `<variant>` |
1008
+ | [[expected]] | Expected objects | `<expected>` |
1009
  | [[function.objects]] | Function objects | `<functional>` |
1010
+ | [[bit]] | Bit manipulation | `<bit>` |
1011
+ | [[stdbit.h.syn]] | C-compatible bit manipulation | `<stdbit.h>` |
1012
+ | [[array]] | Class template `array` | `<array>` |
1013
+ | [[inplace.vector]] | Class template `inplace_vector` | `<inplace_vector>` |
1014
+ | [[views.contiguous]] | Contiguous access | `<span>` |
1015
+ | [[views.multidim]] | Multidimensional access | `<mdspan>` |
1016
  | [[iterators]] | Iterators library | `<iterator>` |
1017
  | [[ranges]] | Ranges library | `<ranges>` |
1018
+ | [[algorithms]] | Algorithms library | `<algorithm>`, `<numeric>` |
1019
+ | [[execpol]] | Execution policies | `<execution>` |
1020
+ | [[string.view]] | String view classes | `<string_view>` |
1021
+ | [[string.classes]] | String classes | `<string>` |
1022
+ | [[c.strings]] | Null-terminated sequence utilities | `<cstring>`, `<cwchar>` |
1023
+ | [[charconv]] | Primitive numeric conversions | `<charconv>` |
1024
+ | [[rand]] | Random number generation | `<random>` |
1025
+ | [[c.math]] | Mathematical functions for floating-point types | `<cmath>` |
1026
+ | [[atomics]] | Atomics | `<atomic>` |
1027
 
1028
 
1029
  For each of the headers listed in [[headers.cpp.fs]], a freestanding
1030
  implementation provides at least the freestanding items
1031
  [[freestanding.item]] declared in the header.
1032
 
1033
+ The *hosted library facilities* are the set of facilities described in
1034
+ this document that are required for hosted implementations, but not
1035
+ required for freestanding implementations. A freestanding implementation
1036
+ provides a (possibly empty) implementation-defined subset of the hosted
1037
+ library facilities. Unless otherwise specified, the requirements on each
1038
+ declaration, entity, and macro provided in this way are the same as the
1039
+ corresponding requirements for a hosted implementation, except that not
1040
+ all of the members of the namespaces are required to be present.
1041
+
1042
+ A freestanding implementation provides deleted definitions
1043
+ [[dcl.fct.def.delete]] for a (possibly empty) implementation-defined
1044
+ subset of the namespace-scope functions and function templates from the
1045
+ hosted library facilities.
1046
+
1047
+ [*Note 1*: An implementation can provide a deleted definition so that
1048
+ the result of overload resolution does not silently change when
1049
+ migrating a program from a freestanding implementation to a hosted
1050
+ implementation. — *end note*]
1051
+
1052
  ### Using the library <a id="using">[[using]]</a>
1053
 
1054
  #### Overview <a id="using.overview">[[using.overview]]</a>
1055
 
1056
  Subclause [[using]] describes how a C++ program gains access to the
 
1187
 
1188
  **Table: Cpp17Destructible requirements** <a id="cpp17.destructible">[cpp17.destructible]</a>
1189
 
1190
  | Expression | Post-condition |
1191
  | ---------- | --------------------------------------------------------------------- |
1192
+ | `a.~T()` | All resources owned by `a` are reclaimed, no exception is propagated. |
1193
  | *[spans 2 columns]* *Array types and non-object types are not Cpp17Destructible.* |
1194
 
1195
 
1196
  #### Swappable requirements <a id="swappable.requirements">[[swappable.requirements]]</a>
1197
 
1198
  This subclause provides definitions for swappable types and expressions.
1199
  In these definitions, let `t` denote an expression of type `T`, and let
1200
  `u` denote an expression of type `U`.
1201
 
1202
+ An object `t` is *swappable with* an object `u` if and only if
1203
 
1204
  - the expressions `swap(t, u)` and `swap(u, t)` are valid when evaluated
1205
  in the context described below, and
1206
  - these expressions have the following effects:
1207
  - the object referred to by `t` has the value originally held by `u`
 
1227
  appropriate evaluation context. — *end note*]
1228
 
1229
  An rvalue or lvalue `t` is *swappable* if and only if `t` is swappable
1230
  with any rvalue or lvalue, respectively, of type `T`.
1231
 
1232
+ A type `X` meets the requirements if lvalues of type `X` are swappable.
 
1233
 
1234
  A type `X` meeting any of the iterator requirements
1235
+ [[iterator.requirements]] meets the requirements if, for any
1236
+ dereferenceable object `x` of type `X`, `*x` is swappable.
1237
 
1238
  [*Example 1*:
1239
 
1240
  User code can ensure that the evaluation of `swap` calls is performed in
1241
  an appropriate context under the various conditions as follows:
 
1285
  — *end example*]
1286
 
1287
  #### *Cpp17NullablePointer* requirements <a id="nullablepointer.requirements">[[nullablepointer.requirements]]</a>
1288
 
1289
  A *Cpp17NullablePointer* type is a pointer-like type that supports null
1290
+ values. A type `P` meets the *Cpp17NullablePointer* requirements if
1291
 
1292
  - `P` meets the *Cpp17EqualityComparable*, *Cpp17DefaultConstructible*,
1293
  *Cpp17CopyConstructible*, *Cpp17CopyAssignable*, *Cpp17Swappable*, and
1294
  *Cpp17Destructible* requirements,
1295
  - the expressions shown in [[cpp17.nullablepointer]] are valid and have
1296
  the indicated semantics, and
1297
  - `P` meets all the other requirements of this subclause.
1298
 
1299
  A value-initialized object of type `P` produces the null value of the
1300
  type. The null value shall be equivalent only to itself. A
1301
+ default-initialized object of type `P` may have an indeterminate or
1302
+ erroneous value.
1303
 
1304
  [*Note 1*: Operations involving indeterminate values can cause
1305
+ undefined behavior, and operations involving erroneous values can cause
1306
+ erroneous behavior [[basic.indet]]. — *end note*]
1307
 
1308
  An object `p` of type `P` can be contextually converted to `bool`
1309
  [[conv]]. The effect shall be as if `p != nullptr` had been evaluated in
1310
  place of `p`.
1311
 
 
1332
  | `np != a` | | |
1333
 
1334
 
1335
  #### *Cpp17Hash* requirements <a id="hash.requirements">[[hash.requirements]]</a>
1336
 
1337
+ A type `H` meets the requirements if
1338
 
1339
  - it is a function object type [[function.objects]],
1340
  - it meets the *Cpp17CopyConstructible* ([[cpp17.copyconstructible]])
1341
  and *Cpp17Destructible* ([[cpp17.destructible]]) requirements, and
1342
  - the expressions shown in [[cpp17.hash]] are valid and have the
 
1359
  which are class-type objects that encapsulate the information about an
1360
  allocation model. This information includes the knowledge of pointer
1361
  types, the type of their difference, the type of the size of objects in
1362
  this allocation model, as well as the memory allocation and deallocation
1363
  primitives for it. All of the string types [[strings]], containers
1364
+ [[containers]] (except `array` and `inplace_vector`), string buffers and
1365
+ string streams [[input.output]], and `match_results` [[re]] are
1366
+ parameterized in terms of allocators.
1367
 
1368
+ In [[allocator.requirements]],
1369
 
1370
  - `T`, `U`, `C` denote any cv-unqualified object type
1371
  [[term.object.type]],
1372
  - `X` denotes an allocator class for type `T`,
1373
  - `Y` denotes the corresponding allocator class for type `U`,
 
1463
  between any two pointers in the allocation model.
1464
 
1465
  *Remarks:* Default: `pointer_traits<XX::pointer>::difference_type`
1466
 
1467
  ``` cpp
1468
+ typename X::rebind<U>::other
1469
  ```
1470
 
1471
  *Result:* `Y`
1472
 
1473
  *Ensures:* For all `U` (including `T`), `YY::rebind_alloc<T>` is `X`.
 
1694
  *Ensures:* `u` is equal to the prior value of `X(b)`.
1695
 
1696
  *Throws:* Nothing.
1697
 
1698
  ``` cpp
1699
+ a.construct(c, args...)
1700
  ```
1701
 
1702
  *Result:* (not used)
1703
 
1704
  *Effects:* Constructs an object of type `C` at `c`.
 
1863
  };
1864
  ```
1865
 
1866
  — *end example*]
1867
 
1868
+ The following exposition-only concept defines the minimal requirements
1869
+ on an Allocator type.
1870
+
1871
+ ``` cpp
1872
+ namespace std {
1873
+ template<class Alloc>
1874
+ concept simple-allocator =
1875
+ requires(Alloc alloc, size_t n) {
1876
+ { *alloc.allocate(n) } -> same_as<typename Alloc::value_type&>;
1877
+ { alloc.deallocate(alloc.allocate(n), n) };
1878
+ } &&
1879
+ copy_constructible<Alloc> &&
1880
+ equality_comparable<Alloc>;
1881
+ }
1882
+ ```
1883
+
1884
+ A type `Alloc` models `simple-allocator` if it meets the requirements of
1885
+ [[allocator.requirements.general]].
1886
+
1887
  ##### Allocator completeness requirements <a id="allocator.requirements.completeness">[[allocator.requirements.completeness]]</a>
1888
 
1889
  If `X` is an allocator class for type `T`, `X` additionally meets the
1890
  allocator completeness requirements if, whether or not `T` is a complete
1891
  type:
 
1915
  if it adds declarations or definitions to namespace `std` or to a
1916
  namespace within namespace `std`.
1917
 
1918
  Unless explicitly prohibited, a program may add a template
1919
  specialization for any standard library class template to namespace
1920
+ `std` provided that
1921
+
1922
+ - the added declaration depends on at least one program-defined type,
1923
+ and
1924
+ - the specialization meets the standard library requirements for the
1925
+ original template.[^21]
1926
 
1927
  The behavior of a C++ program is undefined if it declares an explicit or
1928
  partial specialization of any standard library variable template, except
1929
  where explicitly permitted by the specification of that variable
1930
  template.
 
1942
  - an explicit or partial specialization of any member class template of
1943
  a standard library class or class template, or
1944
  - a deduction guide for any standard library class template.
1945
 
1946
  A program may explicitly instantiate a class template defined in the
1947
+ standard library only if the declaration
1948
+
1949
+ - depends on the name of at least one program-defined type, and
1950
+ - the instantiation meets the standard library requirements for the
1951
+ original template.
1952
 
1953
  Let `F` denote a standard library function [[global.functions]], a
1954
  standard library static member function, or an instantiation of a
1955
  standard library function template. Unless `F` is designated an
1956
  *addressable function*, the behavior of a C++ program is unspecified
 
1966
  ill-formed) if it attempts to form a reference to `F` or if it attempts
1967
  to form a pointer-to-member designating either a standard library
1968
  non-static member function [[member.functions]] or an instantiation of a
1969
  standard library member function template.
1970
 
1971
+ Let `F` denote a standard library function or function template. Unless
1972
+ `F` is designated an addressable function, it is unspecified if or how a
1973
+ reflection value designating the associated entity can be formed.
1974
+
1975
+ [*Note 3*: For example, it is possible that `std::meta::members_of`
1976
+ will not return reflections of standard library functions that an
1977
+ implementation handles through an extra-linguistic
1978
+ mechanism. — *end note*]
1979
+
1980
+ Let `C` denote a standard library class or class template
1981
+ specialization. It is unspecified if or how a reflection value can be
1982
+ formed to any private member of `C`, or what the names of such members
1983
+ may be.
1984
+
1985
  A translation unit shall not declare namespace `std` to be an inline
1986
  namespace [[namespace.def]].
1987
 
1988
  ##### Namespace `posix` <a id="namespace.posix">[[namespace.posix]]</a>
1989
 
1990
  The behavior of a C++ program is undefined if it adds declarations or
1991
  definitions to namespace `posix` or to a namespace within namespace
1992
  `posix` unless otherwise specified. The namespace `posix` is reserved
1993
+ for use by \IsoPosixUndated and other POSIX standards.
1994
 
1995
  ##### Namespaces for future standardization <a id="namespace.future">[[namespace.future]]</a>
1996
 
1997
  Top-level namespaces whose *namespace-name* consists of `std` followed
1998
  by one or more *digit*s [[lex.name]] are reserved for future
 
2016
  reserved, other than as explicitly allowed by [[library]], its behavior
2017
  is undefined.
2018
 
2019
  ##### Zombie names <a id="zombie.names">[[zombie.names]]</a>
2020
 
2021
+ In namespace `std`, the names shown in [[zombie.names.std]] are reserved
2022
+ for previous standardization:
2023
 
2024
+ The names shown in [[zombie.names.objmacro]] are reserved as members for
2025
+ previous standardization, and may not be used as a name for object-like
2026
+ macros in portable code:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2027
 
2028
+ The names shown in [[zombie.names.fnmacro]] are reserved as member
2029
+ functions for previous standardization, and may not be used as a name
2030
+ for function-like macros in portable code:
2031
 
2032
+ The header names shown in [[zombie.names.header]] are reserved for
2033
+ previous standardization:
 
 
 
 
 
 
 
 
 
 
 
 
 
2034
 
2035
  ##### Macro names <a id="macro.names">[[macro.names]]</a>
2036
 
2037
  A translation unit that includes a standard library header shall not
2038
  `#define` or `#undef` names declared in any standard library header.
2039
 
 
 
 
 
 
 
2040
  ##### External linkage <a id="extern.names">[[extern.names]]</a>
2041
 
2042
  Each name declared as an object with external linkage in a header is
2043
  reserved to the implementation to designate that library object with
2044
  external linkage, [^22]
 
2086
  standard library may be overridden in a derived class defined in the
2087
  program [[class.virtual]].
2088
 
2089
  #### Replacement functions <a id="replacement.functions">[[replacement.functions]]</a>
2090
 
2091
+ If a function defined in [[support]] through [[exec]] and [[depr]] is
2092
+ specified as replaceable [[term.replaceable.function]], the description
2093
+ of function semantics apply to both the default version defined by the
2094
+ C++ standard library and the replacement function defined by the
2095
+ program.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2096
 
2097
  #### Handler functions <a id="handler.functions">[[handler.functions]]</a>
2098
 
2099
  The C++ standard library provides a default version of the following
2100
  handler function [[support]]:
 
2115
  calling the following functions:
2116
 
2117
  - `get_new_handler`
2118
  - `get_terminate`
2119
 
2120
+ Calling the `set_*` and `get_*` functions shall not incur a data race
2121
+ [[intro.races]]. A call to any of the `set_*` functions synchronizes
2122
+ with subsequent calls to the same `set_*` function and to the
2123
+ corresponding `get_*` function.
2124
 
2125
  #### Other functions <a id="res.on.functions">[[res.on.functions]]</a>
2126
 
2127
  In certain cases (replacement functions, handler functions, operations
2128
  on types used to instantiate standard library template components), the
 
2130
  these components do not meet their requirements, this document places no
2131
  requirements on the implementation.
2132
 
2133
  In particular, the behavior is undefined in the following cases:
2134
 
2135
+ - For replacement functions [[replacement.functions]], if the installed
2136
+ replacement function does not implement the semantics of the
2137
+ applicable *Required behavior:* paragraph.
2138
  - For handler functions [[new.handler]], [[terminate.handler]], if the
2139
  installed handler function does not implement the semantics of the
2140
  applicable *Required behavior:* paragraph.
2141
  - For types used as template arguments when instantiating a template
2142
  component, if the operations on the type do not implement the
 
2164
  address computations and accesses to objects (that would be valid if
2165
  the pointer did point to the first element of such an array) are in
2166
  fact valid.
2167
  - If a function argument is bound to an rvalue reference parameter, the
2168
  implementation may assume that this parameter is a unique reference to
2169
+ this argument, except that the argument passed to a move assignment
2170
  operator may be a reference to `*this` [[lib.types.movedfrom]].
2171
  \[*Note 1*: If the type of a parameter is a forwarding reference
2172
  [[temp.deduct.call]] that is deduced to an lvalue reference type, then
2173
  the argument is not bound to an rvalue reference. — *end note*]
2174
  \[*Note 2*: If a program casts an lvalue to an xvalue while passing
 
2217
  #### Overview <a id="conforming.overview">[[conforming.overview]]</a>
2218
 
2219
  Subclause [[conforming]] describes the constraints upon, and latitude
2220
  of, implementations of the C++ standard library.
2221
 
2222
+ An implementation’s use of
2223
+
2224
+ - headers is discussed in  [[res.on.headers]],
2225
+ - macros in  [[res.on.macro.definitions]],
2226
+ - non-member functions in  [[global.functions]],
2227
+ - member functions in  [[member.functions]],
2228
+ - data race avoidance in  [[res.on.data.races]],
2229
+ - access specifiers in  [[protection.within.classes]],
2230
+ - class derivation in  [[derivation]],
2231
+ - exceptions in  [[res.on.exception.handling]], and
2232
+ - contract assertions in  [[res.contract.assertions]].
2233
 
2234
  #### Headers <a id="res.on.headers">[[res.on.headers]]</a>
2235
 
2236
  A C++ header may include other C++ headers. A C++ header shall provide
2237
  the declarations and definitions that appear in its synopsis. A C++
 
2261
 
2262
  It is unspecified whether any non-member functions in the C++ standard
2263
  library are defined as inline [[dcl.inline]].
2264
 
2265
  A call to a non-member function signature described in [[support]]
2266
+ through [[exec]] and [[depr]] shall behave as if the implementation
2267
  declared no additional non-member function signatures.[^25]
2268
 
2269
  An implementation shall not declare a non-member function signature with
2270
  additional default arguments.
2271
 
 
2313
  Whenever this document specifies a friend declaration of a function or
2314
  function template within a class or class template definition, that
2315
  declaration shall be the only declaration of that function or function
2316
  template provided by an implementation.
2317
 
2318
+ [*Note 1*: In particular, a conforming implementation does not provide
2319
+ any additional declarations of that function or function template at
2320
  namespace scope. — *end note*]
2321
 
2322
  [*Note 2*: Such a friend function or function template declaration is
2323
  known as a hidden friend, as it is visible neither to ordinary
2324
  unqualified lookup [[basic.lookup.unqual]] nor to qualified lookup
 
2328
 
2329
  This document explicitly requires that certain standard library
2330
  functions are `constexpr` [[dcl.constexpr]]. An implementation shall not
2331
  declare any standard library function signature as `constexpr` except
2332
  for those where it is explicitly required. Within any header that
2333
+ provides any non-defining declarations of constexpr functions an
2334
+ implementation shall provide corresponding definitions.
2335
 
2336
  #### Requirements for stable algorithms <a id="algorithm.stable">[[algorithm.stable]]</a>
2337
 
2338
  When the requirements for an algorithm state that it is “stable” without
2339
  further elaboration, it means:
 
2398
  effects that are visible [[intro.multithread]] to users.
2399
 
2400
  [*Note 3*: This allows implementations to parallelize operations if
2401
  there are no visible side effects. — *end note*]
2402
 
2403
+ #### Properties of library classes <a id="library.class.props">[[library.class.props]]</a>
2404
+
2405
+ Unless explicitly stated otherwise, it is unspecified whether any class
2406
+ described in [[support]] through [[exec]] and [[depr]] is a trivially
2407
+ copyable class, a standard-layout class, or an implicit-lifetime class
2408
+ [[class.prop]].
2409
+
2410
+ Unless explicitly stated otherwise, it is unspecified whether any class
2411
+ for which trivial relocation (i.e., the effects of `trivially_relocate`
2412
+ [[obj.lifetime]]) would be semantically equivalent to move-construction
2413
+ of the destination object followed by destruction of the source object
2414
+ is a trivially relocatable class [[class.prop]].
2415
+
2416
+ Unless explicitly stated otherwise, it is unspecified whether a class
2417
+ `C` is a replaceable class [[class.prop]] if assigning an xvalue `a` of
2418
+ type `C` to an object `b` of type `C` is semantically equivalent to
2419
+ destroying `b` and then constructing from `a` in `b`’s place.
2420
+
2421
  #### Protection within classes <a id="protection.within.classes">[[protection.within.classes]]</a>
2422
 
2423
  It is unspecified whether any function signature or class described in
2424
+ [[support]] through [[exec]] and [[depr]] is a friend of another class
2425
  in the C++ standard library.
2426
 
2427
  #### Derived classes <a id="derivation">[[derivation]]</a>
2428
 
2429
  An implementation may derive any class in the C++ standard library from
 
2451
  #### Restrictions on exception handling <a id="res.on.exception.handling">[[res.on.exception.handling]]</a>
2452
 
2453
  Any of the functions defined in the C++ standard library can report a
2454
  failure by throwing an exception of a type described in its *Throws:*
2455
  paragraph, or of a type derived from a type named in the *Throws:*
2456
+ paragraph that would be caught by a *handler* [[except.handle]] for the
2457
+ base type.
2458
 
2459
  Functions from the C standard library shall not throw exceptions [^26]
2460
 
2461
  except when such a function calls a program-supplied function that
2462
  throws an exception.[^27]
2463
 
2464
  Destructor operations defined in the C++ standard library shall not
2465
  throw exceptions. Every destructor in the C++ standard library shall
2466
+ behave as if it had a non-throwing exception specification
2467
+ [[except.spec]].
2468
 
2469
  Functions defined in the C++ standard library that do not have a
2470
  *Throws:* paragraph but do have a potentially-throwing exception
2471
  specification may throw *implementation-defined* exceptions.[^28]
2472
 
 
2475
  [[bad.alloc]], [[support.exception]], [[std.exceptions]].
2476
 
2477
  An implementation may strengthen the exception specification for a
2478
  non-virtual function by adding a non-throwing exception specification.
2479
 
2480
+ #### Contract assertions <a id="res.contract.assertions">[[res.contract.assertions]]</a>
2481
+
2482
+ Unless specified otherwise, an implementation may check the specified
2483
+ preconditions and postconditions of a function in the C++ standard
2484
+ library using contract assertions
2485
+ [[basic.contract]], [[structure.specifications]].
2486
+
2487
  #### Value of error codes <a id="value.error.codes">[[value.error.codes]]</a>
2488
 
2489
  Certain functions in the C++ standard library report errors via a
2490
+ `error_code` [[syserr.errcode.overview]] object. That object’s
2491
+ `category()` member shall return `system_category()` for errors
2492
  originating from the operating system, or a reference to an
2493
  *implementation-defined* `error_category` object for errors originating
2494
  elsewhere. The implementation shall define the possible values of
2495
  `value()` for each of these error categories.
2496
 
 
2506
  #### Moved-from state of library types <a id="lib.types.movedfrom">[[lib.types.movedfrom]]</a>
2507
 
2508
  Objects of types defined in the C++ standard library may be moved from
2509
  [[class.copy.ctor]]. Move operations may be explicitly specified or
2510
  implicitly generated. Unless otherwise specified, such moved-from
2511
+ objects shall be placed in a valid but unspecified state
2512
+ [[defns.valid]].
2513
 
2514
  An object of a type defined in the C++ standard library may be
2515
  move-assigned [[class.copy.assign]] to itself. Unless otherwise
2516
  specified, such an assignment places the object in a valid but
2517
  unspecified state.
2518
 
2519
  <!-- Link reference definitions -->
2520
  [alg.c.library]: algorithms.md#alg.c.library
2521
+ [alg.func.obj]: #alg.func.obj
2522
  [alg.sorting]: algorithms.md#alg.sorting
2523
  [algorithm.stable]: #algorithm.stable
2524
  [algorithms]: algorithms.md#algorithms
2525
  [algorithms.requirements]: algorithms.md#algorithms.requirements
2526
  [alloc.errors]: support.md#alloc.errors
2527
  [allocator.requirements]: #allocator.requirements
2528
  [allocator.requirements.completeness]: #allocator.requirements.completeness
2529
  [allocator.requirements.general]: #allocator.requirements.general
2530
  [allocator.traits]: mem.md#allocator.traits
2531
  [alt.headers]: #alt.headers
2532
+ [array]: containers.md#array
2533
  [array.creation]: containers.md#array.creation
2534
  [atomics]: thread.md#atomics
2535
  [bad.alloc]: support.md#bad.alloc
2536
+ [basic.contract]: basic.md#basic.contract
2537
+ [basic.contract.eval]: basic.md#basic.contract.eval
2538
  [basic.def.odr]: basic.md#basic.def.odr
2539
  [basic.fundamental]: basic.md#basic.fundamental
2540
+ [basic.indet]: basic.md#basic.indet
2541
  [basic.life]: basic.md#basic.life
2542
  [basic.link]: basic.md#basic.link
2543
  [basic.lookup.argdep]: basic.md#basic.lookup.argdep
2544
  [basic.lookup.qual]: basic.md#basic.lookup.qual
2545
  [basic.lookup.unqual]: basic.md#basic.lookup.unqual
2546
  [basic.scope.namespace]: basic.md#basic.scope.namespace
 
2547
  [basic.stc.dynamic]: basic.md#basic.stc.dynamic
2548
  [bit]: utilities.md#bit
2549
  [bitmask.types]: #bitmask.types
2550
  [byte.strings]: #byte.strings
2551
  [c.annex.k.names]: #c.annex.k.names
2552
+ [c.math]: numerics.md#c.math
2553
+ [c.strings]: strings.md#c.strings
2554
  [cassert.syn]: diagnostics.md#cassert.syn
2555
  [cerrno.syn]: diagnostics.md#cerrno.syn
2556
  [character.seq]: #character.seq
2557
  [character.seq.general]: #character.seq.general
2558
+ [charconv]: text.md#charconv
2559
  [class.copy.assign]: class.md#class.copy.assign
2560
  [class.copy.ctor]: class.md#class.copy.ctor
2561
  [class.dtor]: class.md#class.dtor
2562
  [class.mem]: class.md#class.mem
2563
+ [class.prop]: class.md#class.prop
2564
  [class.virtual]: class.md#class.virtual
2565
+ [clocale.syn]: text.md#clocale.syn
2566
  [cmp]: support.md#cmp
2567
  [compliance]: #compliance
2568
  [concept.destructible]: concepts.md#concept.destructible
2569
  [concept.invocable]: concepts.md#concept.invocable
2570
  [concept.totallyordered]: concepts.md#concept.totallyordered
 
2582
  [conv]: expr.md#conv
2583
  [conv.func]: expr.md#conv.func
2584
  [conventions]: #conventions
2585
  [conventions.general]: #conventions.general
2586
  [cpp.include]: cpp.md#cpp.include
 
2587
  [cpp17.copyassignable]: #cpp17.copyassignable
2588
  [cpp17.copyconstructible]: #cpp17.copyconstructible
2589
  [cpp17.destructible]: #cpp17.destructible
2590
  [cpp17.hash]: #cpp17.hash
2591
  [cpp17.moveassignable]: #cpp17.moveassignable
2592
  [cpp17.nullablepointer]: #cpp17.nullablepointer
2593
  [cstdarg.syn]: support.md#cstdarg.syn
2594
  [cstddef.syn]: support.md#cstddef.syn
2595
  [cstdint.syn]: support.md#cstdint.syn
2596
+ [cstdlib.syn]: support.md#cstdlib.syn
2597
  [customization.point.object]: #customization.point.object
2598
  [dcl.array]: dcl.md#dcl.array
 
2599
  [dcl.constexpr]: dcl.md#dcl.constexpr
2600
+ [dcl.contract.func]: dcl.md#dcl.contract.func
2601
+ [dcl.fct.def.delete]: dcl.md#dcl.fct.def.delete
2602
  [dcl.fct.default]: dcl.md#dcl.fct.default
2603
  [dcl.init]: dcl.md#dcl.init
2604
  [dcl.inline]: dcl.md#dcl.inline
2605
  [dcl.link]: dcl.md#dcl.link
2606
  [dcl.pre]: dcl.md#dcl.pre
2607
  [dcl.typedef]: dcl.md#dcl.typedef
2608
+ [debugging]: diagnostics.md#debugging
2609
+ [defns.const.subexpr]: intro.md#defns.const.subexpr
2610
  [defns.nonconst.libcall]: intro.md#defns.nonconst.libcall
2611
+ [defns.valid]: intro.md#defns.valid
2612
  [depr]: future.md#depr
2613
  [derivation]: #derivation
2614
  [derived.classes]: #derived.classes
2615
  [description]: #description
2616
  [description.general]: #description.general
2617
  [diagnostics]: diagnostics.md#diagnostics
2618
  [enumerated.types]: #enumerated.types
2619
+ [errno]: diagnostics.md#errno
2620
  [except]: except.md#except
2621
+ [except.handle]: except.md#except.handle
2622
+ [except.spec]: except.md#except.spec
2623
+ [exec]: exec.md#exec
2624
+ [execpol]: algorithms.md#execpol
2625
+ [expected]: utilities.md#expected
2626
  [expos.only.entity]: #expos.only.entity
2627
+ [expr.call]: expr.md#expr.call
2628
  [expr.delete]: expr.md#expr.delete
2629
  [expr.new]: expr.md#expr.new
2630
  [expr.unary.op]: expr.md#expr.unary.op
2631
  [extern.names]: #extern.names
2632
  [extern.types]: #extern.types
 
2639
  [headers]: #headers
2640
  [headers.cpp]: #headers.cpp
2641
  [headers.cpp.c]: #headers.cpp.c
2642
  [headers.cpp.fs]: #headers.cpp.fs
2643
  [hidden.friends]: #hidden.friends
2644
+ [inplace.vector]: containers.md#inplace.vector
2645
  [input.output]: input.md#input.output
2646
  [intro.compliance]: intro.md#intro.compliance
2647
  [intro.multithread]: basic.md#intro.multithread
2648
+ [intro.races]: basic.md#intro.races
2649
  [intro.refs]: intro.md#intro.refs
2650
  [iterator.requirements]: iterators.md#iterator.requirements
2651
  [iterators]: iterators.md#iterators
2652
  [lex.charset]: lex.md#lex.charset
2653
  [lex.name]: lex.md#lex.name
 
2654
  [lex.phases]: lex.md#lex.phases
2655
  [lex.separate]: lex.md#lex.separate
2656
  [lib.types.movedfrom]: #lib.types.movedfrom
2657
  [library]: #library
2658
  [library.c]: #library.c
2659
  [library.categories]: #library.categories
2660
+ [library.class.props]: #library.class.props
2661
  [library.general]: #library.general
2662
+ [locales]: text.md#locales
 
2663
  [macro.names]: #macro.names
2664
  [mem]: mem.md#mem
2665
  [member.functions]: #member.functions
2666
  [memory]: mem.md#memory
2667
  [meta]: meta.md#meta
 
2671
  [namespace.def]: dcl.md#namespace.def
2672
  [namespace.future]: #namespace.future
2673
  [namespace.posix]: #namespace.posix
2674
  [namespace.std]: #namespace.std
2675
  [namespace.udecl]: dcl.md#namespace.udecl
 
2676
  [new.handler]: support.md#new.handler
 
2677
  [nullablepointer.requirements]: #nullablepointer.requirements
2678
  [numeric.requirements]: numerics.md#numeric.requirements
2679
  [numerics]: numerics.md#numerics
2680
+ [obj.lifetime]: mem.md#obj.lifetime
2681
  [objects.within.classes]: #objects.within.classes
2682
+ [optional]: utilities.md#optional
2683
  [organization]: #organization
2684
  [organization.general]: #organization.general
2685
  [ostream.iterator.ops]: iterators.md#ostream.iterator.ops
2686
  [over.literal]: over.md#over.literal
2687
  [over.match]: over.md#over.match
2688
  [over.match.oper]: over.md#over.match.oper
2689
  [protection.within.classes]: #protection.within.classes
2690
+ [rand]: numerics.md#rand
2691
  [random.access.iterators]: iterators.md#random.access.iterators
2692
  [ranges]: ranges.md#ranges
2693
  [ratio]: meta.md#ratio
2694
+ [re]: text.md#re
2695
  [reentrancy]: #reentrancy
2696
  [replacement.functions]: #replacement.functions
2697
  [requirements]: #requirements
2698
  [requirements.general]: #requirements.general
2699
+ [res.contract.assertions]: #res.contract.assertions
2700
  [res.on.arguments]: #res.on.arguments
2701
  [res.on.data.races]: #res.on.data.races
2702
  [res.on.exception.handling]: #res.on.exception.handling
2703
  [res.on.functions]: #res.on.functions
2704
  [res.on.headers]: #res.on.headers
 
2708
  [reserved.names]: #reserved.names
2709
  [reserved.names.general]: #reserved.names.general
2710
  [specialized.addressof]: mem.md#specialized.addressof
2711
  [std.exceptions]: diagnostics.md#std.exceptions
2712
  [std.modules]: #std.modules
2713
+ [stdbit.h.syn]: utilities.md#stdbit.h.syn
2714
  [stmt.return]: stmt.md#stmt.return
2715
  [stream.types]: input.md#stream.types
2716
+ [string.classes]: strings.md#string.classes
2717
+ [string.view]: strings.md#string.view
2718
  [strings]: strings.md#strings
2719
  [structure]: #structure
2720
  [structure.elements]: #structure.elements
2721
  [structure.requirements]: #structure.requirements
2722
  [structure.see.also]: #structure.see.also
2723
  [structure.specifications]: #structure.specifications
2724
  [structure.summary]: #structure.summary
2725
  [support]: support.md#support
2726
  [support.c.headers]: support.md#support.c.headers
2727
  [support.c.headers.other]: support.md#support.c.headers.other
2728
+ [support.contract]: support.md#support.contract
2729
  [support.coroutine]: support.md#support.coroutine
2730
  [support.dynamic]: support.md#support.dynamic
2731
  [support.exception]: support.md#support.exception
2732
  [support.initlist]: support.md#support.initlist
2733
  [support.limits]: support.md#support.limits
2734
  [support.rtti]: support.md#support.rtti
2735
  [support.runtime]: support.md#support.runtime
2736
  [support.srcloc]: support.md#support.srcloc
 
2737
  [support.types]: support.md#support.types
2738
  [swappable.requirements]: #swappable.requirements
2739
  [syserr]: diagnostics.md#syserr
2740
  [syserr.errcode.overview]: diagnostics.md#syserr.errcode.overview
2741
  [tab:cpp17.destructible]: #tab:cpp17.destructible
 
2745
  [temp.constr.decl]: temp.md#temp.constr.decl
2746
  [temp.deduct.call]: temp.md#temp.deduct.call
2747
  [template.bitset]: utilities.md#template.bitset
2748
  [term.incomplete.type]: basic.md#term.incomplete.type
2749
  [term.object.type]: basic.md#term.object.type
2750
+ [term.replaceable.function]: dcl.md#term.replaceable.function
2751
  [terminate.handler]: support.md#terminate.handler
2752
+ [text]: text.md#text
2753
  [thread]: thread.md#thread
2754
  [time]: time.md#time
2755
  [tuple]: utilities.md#tuple
2756
  [type.descriptions]: #type.descriptions
2757
  [type.descriptions.general]: #type.descriptions.general
 
2765
  [utility]: utilities.md#utility
2766
  [utility.arg.requirements]: #utility.arg.requirements
2767
  [utility.requirements]: #utility.requirements
2768
  [utility.requirements.general]: #utility.requirements.general
2769
  [value.error.codes]: #value.error.codes
2770
+ [variant]: utilities.md#variant
2771
+ [views.contiguous]: containers.md#views.contiguous
2772
+ [views.multidim]: containers.md#views.multidim
2773
  [zombie.names]: #zombie.names
2774
+ [zombie.names.fnmacro]: #zombie.names.fnmacro
2775
+ [zombie.names.header]: #zombie.names.header
2776
+ [zombie.names.objmacro]: #zombie.names.objmacro
2777
+ [zombie.names.std]: #zombie.names.std
2778
 
2779
+ [^1]: See also ISO/IEC 9899:2018 (C), 7.6.
2780
 
2781
  [^2]: To save space, items that do not apply to a Clause are omitted.
2782
  For example, if a Clause does not specify any requirements, there
2783
  will be no “Requirements” subclause.
2784
 
 
2847
 
2848
  [^19]: This is the same as the C standard library.
2849
 
2850
  [^20]: The only reliable way to declare an object or function signature
2851
  from the C standard library is by including the header that declares
2852
+ it, notwithstanding the latitude granted in ISO/IEC 9899:2018 (C),
2853
+ 7.1.4.
2854
 
2855
  [^21]: Any library code that instantiates other library templates must
2856
  be prepared to work adequately with any user-supplied specialization
2857
  that meets the minimum requirements of this document.
2858
 
 
2871
 
2872
  [^25]: A valid C++ program always calls the expected library non-member
2873
  function. An implementation can also define additional non-member
2874
  functions that would otherwise not be called by a valid C++ program.
2875
 
2876
+ [^26]: That is, the C standard library functions can all be treated as
2877
+ if they are marked `noexcept`. This allows implementations to make
2878
  performance optimizations based on the absence of exceptions at
2879
  runtime.
2880
 
2881
  [^27]: The functions `qsort()` and `bsearch()` [[alg.c.library]] meet
2882
  this condition.