From Jason Turner

[library]

Large diff (114.6 KB) - rendering may be slow on some devices

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpk053w2ss/{from.md → to.md} +924 -627
tmp/tmpk053w2ss/{from.md → to.md} RENAMED
@@ -4,16 +4,16 @@
4
 
5
  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 definitions [[definitions]],
10
- method of description [[description]], and organization [[organization]]
11
- of the library. [[requirements]], [[support]] through [[thread]], and
12
- [[depr]] specify the contents of the library, as well as library
13
- requirements and constraints on both well-formed C++ programs and
14
- conforming 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>
@@ -21,10 +21,12 @@ Detailed specifications for each of the components in the library are in
21
  | Clause | Category |
22
  | ---------------- | --------------------------- |
23
  | [[support]] | Language support library |
24
  | [[concepts]] | Concepts library |
25
  | [[diagnostics]] | Diagnostics library |
 
 
26
  | [[utilities]] | General utilities library |
27
  | [[strings]] | Strings library |
28
  | [[containers]] | Containers library |
29
  | [[iterators]] | Iterators library |
30
  | [[ranges]] | Ranges library |
@@ -32,41 +34,42 @@ Detailed specifications for each of the components in the library are in
32
  | [[numerics]] | Numerics library |
33
  | [[time]] | Time library |
34
  | [[localization]] | Localization library |
35
  | [[input.output]] | Input/output library |
36
  | [[re]] | Regular expressions library |
37
- | [[atomics]] | Atomic operations library |
38
- | [[thread]] | Thread support library |
39
 
40
 
41
  The language support library [[support]] provides components that are
42
- required by certain parts of the C++ language, such as memory
43
- allocation ([[expr.new]], [[expr.delete]]) and exception processing
44
- [[except]].
45
 
46
  The concepts library [[concepts]] describes library components that C++
47
  programs may use to perform compile-time validation of template
48
  arguments and perform function dispatch based on properties of types.
49
 
50
  The diagnostics library [[diagnostics]] provides a consistent framework
51
  for reporting errors in a C++ program, including predefined exception
52
  classes.
53
 
 
 
 
 
 
 
 
54
  The general utilities library [[utilities]] includes components used by
55
  other library elements, such as a predefined storage allocator for
56
  dynamic storage management [[basic.stc.dynamic]], and components used as
57
- infrastructure in C++ programs, such as tuples, function wrappers, and
58
- time facilities.
59
 
60
  The strings library [[strings]] provides support for manipulating text
61
  represented as sequences of type `char`, sequences of type `char8_t`,
62
  sequences of type `char16_t`, sequences of type `char32_t`, sequences of
63
  type `wchar_t`, and sequences of any other character-like type.
64
 
65
- The localization library [[localization]] provides extended
66
- internationalization support for text processing.
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
 
@@ -75,24 +78,26 @@ complex number components that extend support for numeric processing.
75
  The `valarray` component provides support for *n*-at-a-time processing,
76
  potentially implemented as parallel operations on platforms that support
77
  such processing. The random number component provides facilities for
78
  generating pseudo-random numbers.
79
 
 
 
 
 
 
80
  The input/output library [[input.output]] provides the `iostream`
81
  components that are the primary mechanism for C++ program input and
82
  output. They can be used with other elements of the library,
83
  particularly strings, locales, and iterators.
84
 
85
  The regular expressions library [[re]] provides regular expression
86
  matching and searching.
87
 
88
- The atomic operations library [[atomics]] allows more fine-grained
89
- concurrent access to shared data than is possible with locks.
90
-
91
- The thread support library [[thread]] provides components to create and
92
- manage threads, including mutual exclusion and interthread
93
- communication.
94
 
95
  ## The C standard library <a id="library.c">[[library.c]]</a>
96
 
97
  The C++ standard library also makes available the facilities of the C
98
  standard library, suitably adjusted to ensure static type safety.
@@ -103,261 +108,41 @@ signatures specified in this document may be different from the
103
  signatures in the C standard library, and additional overloads may be
104
  declared in this document, but the behavior and the preconditions
105
  (including any preconditions implied by the use of an ISO C `restrict`
106
  qualifier) are the same unless otherwise stated.
107
 
108
- ## Definitions <a id="definitions">[[definitions]]</a>
109
-
110
- [*Note 1*: [[intro.defs]] defines additional terms used elsewhere in
111
- this document. *end note*]
112
-
113
- #### 1 arbitrary-positional stream <a id="defns.arbitrary.stream">[[defns.arbitrary.stream]]</a>
114
-
115
- stream (described in [[input.output]]) that can seek to any integral
116
- position within the length of the stream
117
-
118
- [*Note 1 to entry*: Every arbitrary-positional stream is also a
119
- repositional stream. — *end note*]
120
-
121
- #### 2 character <a id="defns.character">[[defns.character]]</a>
122
-
123
- ⟨[[strings]], [[localization]], [[input.output]], and~ [[re]]⟩
124
- object which, when treated sequentially, can represent text
125
-
126
- [*Note 1 to entry*: The term does not mean only `char`, `char8_t`,
127
- `char16_t`, `char32_t`, and `wchar_t` objects, but any value that can be
128
- represented by a type that provides the definitions specified in these
129
- Clauses. — *end note*]
130
-
131
- #### 3 character container type <a id="defns.character.container">[[defns.character.container]]</a>
132
-
133
- class or a type used to represent a character
134
-
135
- [*Note 1 to entry*: It is used for one of the template parameters of
136
- the string, iostream, and regular expression class
137
- templates. — *end note*]
138
-
139
- #### 4 comparison function <a id="defns.comparison">[[defns.comparison]]</a>
140
-
141
- operator function [[over.oper]] for any of the equality [[expr.eq]],
142
- relational [[expr.rel]], or three-way comparison [[expr.spaceship]]
143
- operators
144
-
145
- #### 5 component <a id="defns.component">[[defns.component]]</a>
146
-
147
- group of library entities directly related as members, parameters, or
148
- return types
149
-
150
- [*Note 1 to entry*: For example, the class template `basic_string` and
151
- the non-member function templates that operate on strings are referred
152
- to as the *string component*. — *end note*]
153
-
154
- #### 6 constant subexpression <a id="defns.const.subexpr">[[defns.const.subexpr]]</a>
155
-
156
- expression whose evaluation as subexpression of a
157
- *conditional-expression* `CE` [[expr.cond]] would not prevent `CE` from
158
- being a core constant expression [[expr.const]]
159
-
160
- #### 7 deadlock <a id="defns.deadlock">[[defns.deadlock]]</a>
161
-
162
- situation wherein one or more threads are unable to continue execution
163
- because each is blocked waiting for one or more of the others to satisfy
164
- some condition
165
-
166
- #### 8 default behavior <a id="defns.default.behavior.impl">[[defns.default.behavior.impl]]</a>
167
-
168
- ⟨implementation⟩ specific behavior provided by the implementation,
169
- within the scope of the required behavior
170
-
171
- #### 9 default behavior <a id="defns.default.behavior.func">[[defns.default.behavior.func]]</a>
172
-
173
- ⟨specification⟩ description of replacement function and handler function
174
- semantics
175
-
176
- #### 10 direct-non-list-initialization <a id="defns.direct-non-list-init">[[defns.direct-non-list-init]]</a>
177
-
178
- direct-initialization [[dcl.init]] that is not list-initialization
179
- [[dcl.init.list]]
180
-
181
- #### 11 expression-equivalent <a id="defns.expression-equivalent">[[defns.expression-equivalent]]</a>
182
-
183
- expressions that all have the same effects, either are all
184
- potentially-throwing [[except.spec]] or are all not
185
- potentially-throwing, and either are all constant subexpressions or are
186
- all not constant subexpressions
187
-
188
- [*Example 1*: For a value `x` of type `int` and a function `f` that
189
- accepts integer arguments, the expressions `f(x + 2)`, `f(2 + x)`, and
190
- `f(1 + x + 1)` are expression-equivalent. — *end example*]
191
-
192
- #### 12 handler function <a id="defns.handler">[[defns.handler]]</a>
193
-
194
- non-reserved function whose definition may be provided by a C++ program
195
-
196
- [*Note 1 to entry*: A C++ program may designate a handler function at
197
- various points in its execution by supplying a pointer to the function
198
- when calling any of the library functions that install handler functions
199
- [[support]]. — *end note*]
200
-
201
- #### 13 implementation-defined strict total order over pointers <a id="defns.order.ptr">[[defns.order.ptr]]</a>
202
-
203
- *implementation-defined* strict total ordering over all pointer values
204
- such that the ordering is consistent with the partial order imposed by
205
- the builtin operators `<`, `>`, `<=`, `>=`, and `<=>`
206
-
207
- #### 14 iostream class templates <a id="defns.iostream.templates">[[defns.iostream.templates]]</a>
208
-
209
- templates, defined in [[input.output]], that take two template arguments
210
-
211
- [*Note 1 to entry*: The arguments are named `charT` and `traits`. The
212
- argument `charT` is a character container class, and the argument
213
- `traits` is a class which defines additional characteristics and
214
- functions of the character type represented by `charT` necessary to
215
- implement the iostream class templates. — *end note*]
216
-
217
- #### 15 modifier function <a id="defns.modifier">[[defns.modifier]]</a>
218
-
219
- class member function [[class.mfct]] other than a constructor,
220
- assignment operator, or destructor that alters the state of an object of
221
- the class
222
-
223
- #### 16 move assignment <a id="defns.move.assign">[[defns.move.assign]]</a>
224
-
225
- assignment of an rvalue of some object type to a modifiable lvalue of
226
- the same type
227
-
228
- #### 17 move construction <a id="defns.move.constr">[[defns.move.constr]]</a>
229
-
230
- direct-initialization of an object of some type with an rvalue of the
231
- same type
232
-
233
- #### 18 NTCTS <a id="defns.ntcts">[[defns.ntcts]]</a>
234
-
235
- sequence of values that have character type that precede the terminating
236
- null character type value `charT()`
237
-
238
- #### 19 observer function <a id="defns.observer">[[defns.observer]]</a>
239
-
240
- class member function [[class.mfct]] that accesses the state of an
241
- object of the class but does not alter that state
242
-
243
- [*Note 1 to entry*: Observer functions are specified as `const` member
244
- functions [[class.this]]. — *end note*]
245
-
246
- #### 20 program-defined specialization <a id="defns.prog.def.spec">[[defns.prog.def.spec]]</a>
247
-
248
- explicit template specialization or partial specialization that is not
249
- part of the C++ standard library and not defined by the implementation
250
-
251
- #### 21 program-defined type <a id="defns.prog.def.type">[[defns.prog.def.type]]</a>
252
-
253
- non-closure class type or enumeration type that is not part of the C++
254
- standard library and not defined by the implementation, or a closure
255
- type of a non-implementation-provided lambda expression, or an
256
- instantiation of a program-defined specialization
257
-
258
- [*Note 1 to entry*: Types defined by the implementation include
259
- extensions [[intro.compliance]] and internal types used by the
260
- library. — *end note*]
261
-
262
- #### 22 projection <a id="defns.projection">[[defns.projection]]</a>
263
-
264
- ⟨function object argument⟩ transformation that an algorithm applies
265
- before inspecting the values of elements
266
-
267
- [*Example 1*:
268
-
269
- ``` cpp
270
- std::pair<int, std::string_view> pairs[] = {{2, "foo"}, {1, "bar"}, {0, "baz"}};
271
- std::ranges::sort(pairs, std::ranges::less{}, [](auto const& p) { return p.first; });
272
- ```
273
-
274
- sorts the pairs in increasing order of their `first` members:
275
-
276
- ``` cpp
277
- {{0, "baz"}, {1, "bar"}, {2, "foo"}}
278
- ```
279
-
280
- — *end example*]
281
-
282
- #### 23 referenceable type <a id="defns.referenceable">[[defns.referenceable]]</a>
283
-
284
- type that is either an object type, a function type that does not have
285
- cv-qualifiers or a *ref-qualifier*, or a reference type
286
-
287
- [*Note 1 to entry*: The term describes a type to which a reference can
288
- be created, including reference types. — *end note*]
289
-
290
- #### 24 replacement function <a id="defns.replacement">[[defns.replacement]]</a>
291
-
292
- non-reserved function whose definition is provided by a C++ program
293
-
294
- [*Note 1 to entry*: Only one definition for such a function is in
295
- effect for the duration of the program’s execution, as the result of
296
- creating the program [[lex.phases]] and resolving the definitions of all
297
- translation units [[basic.link]]. — *end note*]
298
-
299
- #### 25 repositional stream <a id="defns.repositional.stream">[[defns.repositional.stream]]</a>
300
-
301
- stream (described in [[input.output]]) that can seek to a position that
302
- was previously encountered
303
-
304
- #### 26 required behavior <a id="defns.required.behavior">[[defns.required.behavior]]</a>
305
-
306
- description of replacement function and handler function semantics
307
- applicable to both the behavior provided by the implementation and the
308
- behavior of any such function definition in the program
309
-
310
- [*Note 1 to entry*: If such a function defined in a C++ program fails
311
- to meet the required behavior when it executes, the behavior is
312
- undefined. — *end note*]
313
-
314
- #### 27 reserved function <a id="defns.reserved.function">[[defns.reserved.function]]</a>
315
-
316
- function, specified as part of the C++ standard library, that is defined
317
- by the implementation
318
-
319
- [*Note 1 to entry*: If a C++ program provides a definition for any
320
- reserved function, the results are undefined. — *end note*]
321
-
322
- #### 28 stable algorithm <a id="defns.stable">[[defns.stable]]</a>
323
-
324
- algorithm that preserves, as appropriate to the particular algorithm,
325
- the order of elements
326
-
327
- [*Note 1 to entry*: Requirements for stable algorithms are given in
328
- [[algorithm.stable]]. — *end note*]
329
-
330
- #### 29 traits class <a id="defns.traits">[[defns.traits]]</a>
331
-
332
- class that encapsulates a set of types and functions necessary for class
333
- templates and function templates to manipulate objects of types for
334
- which they are instantiated
335
-
336
- #### 30 valid but unspecified state <a id="defns.valid">[[defns.valid]]</a>
337
-
338
- value of an object that is not specified except that the object’s
339
- invariants are met and operations on the object behave as specified for
340
- its type
341
-
342
- [*Example 1*: If an object `x` of type `std::vector<int>` is in a valid
343
- but unspecified state, `x.empty()` can be called unconditionally, and
344
- `x.front()` can be called only if `x.empty()` returns
345
- `false`. — *end example*]
346
 
347
  ## Method of description <a id="description">[[description]]</a>
348
 
349
- This subclause describes the conventions used to specify the C++
350
- standard library. [[structure]] describes the structure of the normative
 
 
351
  [[support]] through [[thread]] and [[depr]]. [[conventions]] describes
352
  other editorial conventions.
353
 
354
  ### Structure of each clause <a id="structure">[[structure]]</a>
355
 
356
  #### Elements <a id="structure.elements">[[structure.elements]]</a>
357
 
358
- Each library clause contains the following elements, as applicable:[^1]
359
 
360
  - Summary
361
  - Requirements
362
  - Detailed specifications
363
  - References to the C standard library
@@ -422,11 +207,11 @@ Template argument requirements are sometimes referenced by name. See 
422
  [[type.descriptions]].
423
 
424
  In some cases the semantic requirements are presented as C++ code. Such
425
  code is intended as a specification of equivalence of a construct to
426
  another construct, not necessarily as the way the construct must be
427
- implemented.[^2]
428
 
429
  Required operations of any concept defined in this document need not be
430
  total functions; that is, some arguments to a required operation may
431
  result in the required semantics failing to be met.
432
 
@@ -450,43 +235,49 @@ The detailed specifications each contain the following elements:
450
  - restrictions on template arguments, if any
451
  - description of class invariants
452
  - description of function semantics
453
 
454
  Descriptions of class member functions follow the order (as
455
- appropriate):[^3]
456
 
457
  - constructor(s) and destructor
458
  - copying, moving & assignment functions
459
- - comparison functions
460
  - modifier functions
461
  - observer functions
462
  - operators and other non-member functions
463
 
464
  Descriptions of function semantics contain the following elements (as
465
- appropriate):[^4]
466
 
467
  - *Constraints:* the conditions for the function’s participation in
468
  overload resolution [[over.match]]. \[*Note 1*: Failure to meet such a
469
  condition results in the function’s silent
470
- non-viability. — *end note*] \[*Example 1*: An implementation might
471
  express such a condition via a *constraint-expression*
472
  [[temp.constr.decl]]. — *end example*]
473
  - *Mandates:* the conditions that, if not met, render the program
474
- ill-formed. \[*Example 2*: An implementation might express such a
475
  condition via the *constant-expression* in a
476
  *static_assert-declaration* [[dcl.pre]]. If the diagnostic is to be
477
  emitted only after the function has been selected by overload
478
- resolution, an implementation might express such a condition via a
479
  *constraint-expression* [[temp.constr.decl]] and also define the
480
  function as deleted. — *end example*]
481
  - *Preconditions:* the conditions that the function assumes to hold
482
- whenever it is called.
 
483
  - *Effects:* the actions performed by the function.
484
  - *Synchronization:* the synchronization operations
485
  [[intro.multithread]] applicable to the function.
486
  - *Ensures:* the conditions (sometimes termed observable results)
487
  established by the function.
 
 
 
 
 
488
  - *Returns:* a description of the value(s) returned by the function.
489
  - *Throws:* any exceptions thrown by the function, and the conditions
490
  that would cause the exception.
491
  - *Complexity:* the time and/or space complexity of the function.
492
  - *Remarks:* additional semantic constraints on the function.
@@ -516,11 +307,11 @@ definition provided by the implementation. The *required behavior*
516
  describes the semantics of a function definition provided by either the
517
  implementation or a C++ program. Where no distinction is explicitly made
518
  in the description, the behavior described is the required behavior.
519
 
520
  If the formulation of a complexity requirement calls for a negative
521
- number of operations, the actual requirement is zero operations.[^5]
522
 
523
  Complexity requirements specified in the library clauses are upper
524
  bounds, and implementations that provide better complexity guarantees
525
  meet the requirements.
526
 
@@ -534,26 +325,32 @@ Paragraphs labeled “<span class="smallcaps">See also</span>” contain
534
  cross-references to the relevant portions of other standards
535
  [[intro.refs]].
536
 
537
  ### Other conventions <a id="conventions">[[conventions]]</a>
538
 
539
- This subclause describes several editorial conventions used to describe
540
- the contents of the C++ standard library. These conventions are for
541
- describing implementation-defined types [[type.descriptions]], and
542
- member functions [[functions.within.classes]].
543
 
544
- #### Exposition-only functions <a id="expos.only.func">[[expos.only.func]]</a>
 
 
 
545
 
546
- Several function templates defined in [[support]] through [[thread]] and
547
- [[depr]] are only defined for the purpose of exposition. The declaration
548
- of such a function is followed by a comment ending in *exposition only*.
 
 
 
549
 
550
  The following are defined for exposition only to aid in the
551
  specification of the library:
552
 
553
  ``` cpp
554
- template<class T> constexpr decay_t<T> decay-copy(T&& v)
 
 
 
555
  noexcept(is_nothrow_convertible_v<T, decay_t<T>>) // exposition only
556
  { return std::forward<T>(v); }
557
 
558
  constexpr auto synth-three-way =
559
  []<class T, class U>(const T& t, const U& u)
@@ -571,49 +368,33 @@ constexpr auto synth-three-way =
571
  }
572
  };
573
 
574
  template<class T, class U=T>
575
  using synth-three-way-result = decltype(synth-three-way(declval<T&>(), declval<U&>()));
 
576
  ```
577
 
578
  #### Type descriptions <a id="type.descriptions">[[type.descriptions]]</a>
579
 
580
  ##### General <a id="type.descriptions.general">[[type.descriptions.general]]</a>
581
 
582
  The Requirements subclauses may describe names that are used to specify
583
- constraints on template arguments.[^6] These names are used in library
584
- Clauses to describe the types that may be supplied as arguments by a C++
585
- program when instantiating template components from the library.
 
 
586
 
587
  Certain types defined in [[input.output]] are used to describe
588
  implementation-defined types. They are based on other types, but with
589
  added constraints.
590
 
591
- ##### Exposition-only types <a id="expos.only.types">[[expos.only.types]]</a>
592
-
593
- Several types defined in [[support]] through [[thread]] and [[depr]] are
594
- defined for the purpose of exposition. The declaration of such a type is
595
- followed by a comment ending in *exposition only*.
596
-
597
- [*Example 1*:
598
-
599
- ``` cpp
600
- namespace std {
601
- extern "C" using some-handler = int(int, void*, double); // exposition only
602
- }
603
- ```
604
-
605
- The type placeholder `some-handler` can now be used to specify a
606
- function that takes a callback parameter with C language linkage.
607
-
608
- — *end example*]
609
-
610
  ##### Enumerated types <a id="enumerated.types">[[enumerated.types]]</a>
611
 
612
  Several types defined in [[input.output]] are *enumerated types*. Each
613
  enumerated type may be implemented as an enumeration or as a synonym for
614
- an enumeration.[^7]
615
 
616
  The enumerated type `enumerated` can be written:
617
 
618
  ``` cpp
619
  enum enumerated { V₀, V₁, V₂, V₃, … };
@@ -691,24 +472,36 @@ The following terms apply to objects and values of bitmask types:
691
  - The value *Y* *is set* in the object *X* if the expression *X* `&` *Y*
692
  is nonzero.
693
 
694
  ##### Character sequences <a id="character.seq">[[character.seq]]</a>
695
 
 
 
696
  The C standard library makes widespread use of characters and character
697
  sequences that follow a few uniform conventions:
698
 
 
 
 
 
 
 
 
 
 
 
 
 
699
  - A *letter* is any of the 26 lowercase or 26 uppercase letters in the
700
- basic execution character set.
701
- - The *decimal-point character* is the (single-byte) character used by
702
- functions that convert between a (single-byte) character sequence and
703
- a value of one of the floating-point types. It is used in the
704
- character sequence to denote the beginning of a fractional part. It is
705
- represented in [[support]] through [[thread]] and [[depr]] by a
706
- period, `'.'`, which is also its value in the `"C"` locale, but may
707
- change during program execution by a call to
708
- `setlocale(int, const char*)`,[^8] or by a change to a `locale`
709
- object, as described in [[locales]] and [[input.output]].
710
  - A *character sequence* is an array object [[dcl.array]] `A` that can
711
  be declared as `T A[N]`, where `T` is any of the types `char`,
712
  `unsigned char`, or `signed char` [[basic.fundamental]], optionally
713
  qualified by any combination of `const` or `volatile`. The initial
714
  elements of the array have defined contents up to and including an
@@ -730,10 +523,14 @@ and including the terminating null character.
730
 
731
  A *static NTBS* is an NTBS with static storage duration.[^10]
732
 
733
  ###### Multibyte strings <a id="multibyte.strings">[[multibyte.strings]]</a>
734
 
 
 
 
 
735
  A *null-terminated multibyte string*, or NTMBS, is an NTBS that
736
  constitutes a sequence of valid multibyte characters, beginning and
737
  ending in the initial shift state.[^11]
738
 
739
  A *static NTMBS* is an NTMBS with static storage duration.
@@ -746,44 +543,46 @@ while enforcing semantic requirements on that interaction.
746
 
747
  The type of a customization point object, ignoring cv-qualifiers, shall
748
  model `semiregular` [[concepts.object]].
749
 
750
  All instances of a specific customization point object type shall be
751
- equal [[concepts.equality]].
 
 
752
 
753
- The type `T` of a customization point object shall model
754
- `invocable<const T&, Args...>` [[concept.invocable]] when the types in
755
- `Args...` meet the requirements specified in that customization point
756
- object’s definition. When the types of `Args...` do not meet the
757
- customization point object’s requirements, `T` shall not have a function
758
- call operator that participates in overload resolution.
 
 
 
 
 
 
 
 
 
 
 
 
759
 
760
  Each customization point object type constrains its return type to model
761
  a particular concept.
762
 
763
- [*Note 1*: Many of the customization point objects in the library
764
- evaluate function call expressions with an unqualified name which
765
- results in a call to a program-defined function found by argument
766
- dependent name lookup [[basic.lookup.argdep]]. To preclude such an
767
- expression resulting in a call to unconstrained functions with the same
768
- name in namespace `std`, customization point objects specify that lookup
769
- for these expressions is performed in a context that includes deleted
770
- overloads matching the signatures of overloads defined in namespace
771
- `std`. When the deleted overloads are viable, program-defined overloads
772
- need be more specialized [[temp.func.order]] or more constrained
773
- [[temp.constr.order]] to be used by a customization point
774
- object. — *end note*]
775
-
776
  #### Functions within classes <a id="functions.within.classes">[[functions.within.classes]]</a>
777
 
778
  For the sake of exposition, [[support]] through [[thread]] and [[depr]]
779
  do not describe copy/move constructors, assignment operators, or
780
  (non-virtual) destructors with the same apparent semantics as those that
781
- can be generated by default ([[class.copy.ctor]],
782
- [[class.copy.assign]], [[class.dtor]]). It is unspecified whether the
783
- implementation provides explicit definitions for such member function
784
- signatures, or for virtual destructors that can be generated by default.
 
785
 
786
  #### Private members <a id="objects.within.classes">[[objects.within.classes]]</a>
787
 
788
  [[support]] through [[thread]] and [[depr]] do not specify the
789
  representation of classes, and intentionally omit specification of class
@@ -803,28 +602,87 @@ streambuf* sb; // exposition only
803
  ```
804
 
805
  An implementation may use any technique that provides equivalent
806
  observable behavior.
807
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
808
  ## Library-wide requirements <a id="requirements">[[requirements]]</a>
809
 
810
- This subclause specifies requirements that apply to the entire C++
811
- standard library. [[support]] through [[thread]] and [[depr]] specify
812
- the requirements of individual entities within the library.
 
 
813
 
814
  Requirements specified in terms of interactions between threads do not
815
  apply to programs having only a single thread of execution.
816
 
817
- Within this subclause, [[organization]] describes the library’s contents
818
- and organization, [[using]] describes how well-formed C++ programs gain
819
- access to library entities, [[utility.requirements]] describes
820
- constraints on types and functions used with the C++ standard library,
821
- [[constraints]] describes constraints on well-formed C++ programs, and
822
- [[conforming]] describes constraints on conforming implementations.
823
 
824
  ### Library contents and organization <a id="organization">[[organization]]</a>
825
 
 
 
826
  [[contents]] describes the entities and macros defined in the C++
827
  standard library. [[headers]] lists the standard library headers and
828
  some constraints on those headers. [[compliance]] lists requirements for
829
  a freestanding implementation of the C++ standard library.
830
 
@@ -834,19 +692,40 @@ The C++ standard library provides definitions for the entities and
834
  macros described in the synopses of the C++ standard library headers
835
  [[headers]], unless otherwise specified.
836
 
837
  All library entities except `operator new` and `operator delete` are
838
  defined within the namespace `std` or namespaces nested within namespace
839
- `std`.[^12] It is unspecified whether names declared in a specific
840
- namespace are declared directly in that namespace or in an inline
841
- namespace inside that namespace.[^13]
842
-
843
- Whenever a name `x` defined in the standard library is mentioned, the
844
- name `x` is assumed to be fully qualified as `::std::x`, unless
845
- explicitly described otherwise. For example, if the *Effects:* element
846
- for library function `F` is described as calling library function `G`,
847
- the function `::std::G` is meant.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
848
 
849
  #### Headers <a id="headers">[[headers]]</a>
850
 
851
  Each element of the C++ standard library is declared or defined (as
852
  appropriate) in a *header*.[^14]
@@ -860,12 +739,12 @@ headers shown in [[headers.cpp.c]]. [^15]
860
  The headers listed in [[headers.cpp]], or, for a freestanding
861
  implementation, the subset of such headers that are provided by the
862
  implementation, are collectively known as the
863
  *importable C++ library headers*.
864
 
865
- [*Note 1*: Importable C++ library headers can be imported as module
866
- units [[module.import]]. — *end note*]
867
 
868
  [*Example 1*:
869
 
870
  ``` cpp
871
  import <vector>; // imports the <vector> header unit
@@ -897,12 +776,12 @@ Names that are defined as functions in C shall be defined as functions
897
  in the C++ standard library.[^16]
898
 
899
  Identifiers that are keywords or operators in C++ shall not be defined
900
  as macros in C++ standard library headers.[^17]
901
 
902
- [[depr.c.headers]], C standard library headers, describes the effects of
903
- using the `name.h` (C header) form in a C++ program.[^18]
904
 
905
  Annex K of the C standard describes a large number of functions, with
906
  associated types and macros, which “promote safer, more secure
907
  programming” than many of the traditional C library functions. The names
908
  of the functions have a suffix of `_s`; most of them provide the same
@@ -914,13 +793,54 @@ global namespace. (None of them is declared in namespace `std`.)
914
 
915
  [[c.annex.k.names]] lists the Annex K names that may be declared in some
916
  header. These names are also subject to the restrictions of 
917
  [[macro.names]].
918
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
919
  #### Freestanding implementations <a id="compliance">[[compliance]]</a>
920
 
921
- Two kinds of implementations are defined: *hosted* and *freestanding*
922
  [[intro.compliance]]; the kind of the implementation is
923
  *implementation-defined*. For a hosted implementation, this document
924
  describes the set of available headers.
925
 
926
  A freestanding implementation has an *implementation-defined* set of
@@ -928,39 +848,39 @@ headers. This set shall include at least the headers shown in
928
  [[headers.cpp.fs]].
929
 
930
  **Table: C++ headers for freestanding implementations** <a id="headers.cpp.fs">[headers.cpp.fs]</a>
931
 
932
  | Subclause | | Header |
933
- | ---------------------- | ------------------------- | ------------------------------------------------ |
934
- | [[support.types]] | Types | `<cstddef>` |
935
  | [[support.limits]] | Implementation properties | `<cfloat>`, `<climits>`, `<limits>`, `<version>` |
936
- | [[cstdint]] | Integer types | `<cstdint>` |
937
  | [[support.start.term]] | Start and termination | `<cstdlib>` |
938
  | [[support.dynamic]] | Dynamic memory management | `<new>` |
939
  | [[support.rtti]] | Type identification | `<typeinfo>` |
940
  | [[support.srcloc]] | Source location | `<source_location>` |
941
  | [[support.exception]] | Exception handling | `<exception>` |
942
  | [[support.initlist]] | Initializer lists | `<initializer_list>` |
943
  | [[cmp]] | Comparisons | `<compare>` |
944
  | [[support.coroutine]] | Coroutines support | `<coroutine>` |
945
  | [[support.runtime]] | Other runtime support | `<cstdarg>` |
946
  | [[concepts]] | Concepts library | `<concepts>` |
947
- | [[meta]] | Type traits | `<type_traits>` |
948
  | [[bit]] | Bit manipulation | `<bit>` |
949
  | [[atomics]] | Atomics | `<atomic>` |
 
 
 
 
 
 
 
950
 
951
 
952
- The supplied version of the header `<cstdlib>` shall declare at least
953
- the functions `abort`, `atexit`, `at_quick_exit`, `exit`, and
954
- `quick_exit` [[support.start.term]]. The supplied version of the header
955
- `<atomic>` shall meet the same requirements as for a hosted
956
- implementation except that support for always lock-free integral atomic
957
- types [[atomics.lockfree]] is *implementation-defined*, and whether or
958
- not the type aliases `atomic_signed_lock_free` and
959
- `atomic_unsigned_lock_free` are defined [[atomics.alias]] is
960
- *implementation-defined*. The other headers listed in this table shall
961
- meet the same requirements as for a hosted implementation.
962
 
963
  ### Using the library <a id="using">[[using]]</a>
964
 
965
  #### Overview <a id="using.overview">[[using.overview]]</a>
966
 
@@ -1006,10 +926,12 @@ program are included in the program prior to program startup.
1006
  See also replacement functions [[replacement.functions]], runtime
1007
  changes [[handler.functions]].
1008
 
1009
  ### Requirements on types and expressions <a id="utility.requirements">[[utility.requirements]]</a>
1010
 
 
 
1011
  [[utility.arg.requirements]] describes requirements on types and
1012
  expressions used to instantiate templates defined in the C++ standard
1013
  library. [[swappable.requirements]] describes the requirements on
1014
  swappable types and swappable expressions.
1015
  [[nullablepointer.requirements]] describes the requirements on
@@ -1021,33 +943,38 @@ allocators.
1021
  #### Template argument requirements <a id="utility.arg.requirements">[[utility.arg.requirements]]</a>
1022
 
1023
  The template definitions in the C++ standard library refer to various
1024
  named requirements whose details are set out in Tables 
1025
  [[tab:cpp17.equalitycomparable]]– [[tab:cpp17.destructible]]. In these
1026
- tables, `T` is an object or reference type to be supplied by a C++
1027
- program instantiating a template; `a`, `b`, and `c` are values of type
1028
- (possibly `const`) `T`; `s` and `t` are modifiable lvalues of type `T`;
1029
- `u` denotes an identifier; `rv` is an rvalue of type `T`; and `v` is an
1030
- lvalue of type (possibly `const`) `T` or an rvalue of type `const T`.
 
 
 
 
 
1031
 
1032
  In general, a default constructor is not required. Certain container
1033
  class member function signatures specify `T()` as a default argument.
1034
  `T()` shall be a well-defined expression [[dcl.init]] if one of those
1035
  signatures is called using the default argument [[dcl.fct.default]].
1036
 
1037
  **Table: Cpp17EqualityComparable requirements** <a id="cpp17.equalitycomparable">[cpp17.equalitycomparable]</a>
1038
 
1039
  | Expression | Return type |
1040
  | ---------- | ----------- |
1041
- | `a == b` | convertible to `bool` | `==` is an equivalence relation, that is, it has the following properties: For all `a`, `a == a`.; If `a == b`, then `b == a`.; If `a == b` and `b == c`, then `a == c`. |
1042
 
1043
 
1044
  **Table: Cpp17LessThanComparable requirements** <a id="cpp17.lessthancomparable">[cpp17.lessthancomparable]</a>
1045
 
1046
  | Expression | Return type | Requirement |
1047
- | ---------- | --------------------- | ------------------------------------------------------ |
1048
- | `a < b` | convertible to `bool` | `<` is a strict weak ordering relation [[alg.sorting]] |
1049
 
1050
 
1051
  **Table: Cpp17DefaultConstructible requirements** <a id="cpp17.defaultconstructible">[cpp17.defaultconstructible]</a>
1052
 
1053
  | Expression | Post-condition |
@@ -1055,37 +982,49 @@ signatures is called using the default argument [[dcl.fct.default]].
1055
  | `T t;` | object `t` is default-initialized |
1056
  | `T u{};` | object `u` is value-initialized or aggregate-initialized |
1057
  | `T()`<br>`T{}` | an object of type `T` is value-initialized or aggregate-initialized |
1058
 
1059
 
1060
- [*Note 1*: `rv` must still meet the requirements of the library
1061
- component that is using it. The operations listed in those requirements
1062
- must work as specified whether `rv` has been moved from or
1063
- not. *end note*]
 
 
 
 
1064
 
1065
  **Table: Cpp17CopyConstructible requirements (in addition to Cpp17MoveConstructible)** <a id="cpp17.copyconstructible">[cpp17.copyconstructible]</a>
1066
 
1067
  | Expression | Post-condition |
1068
  | ---------- | --------------------------------------------------------- |
1069
  | `T u = v;` | the value of `v` is unchanged and is equivalent to ` u` |
1070
  | `T(v)` | the value of `v` is unchanged and is equivalent to `T(v)` |
1071
 
1072
 
1073
- [*Note 2*:  `rv` must still meet the requirements of the library
1074
- component that is using it, whether or not `t` and `rv` refer to the
1075
- same object. The operations listed in those requirements must work as
1076
- specified whether `rv` has been moved from or not. — *end note*]
 
 
 
1077
 
1078
  **Table: Cpp17CopyAssignable requirements (in addition to Cpp17MoveAssignable)** <a id="cpp17.copyassignable">[cpp17.copyassignable]</a>
1079
 
1080
  | Expression | Return type | Return value | Post-condition |
1081
  | ---------- | ----------- | ------------ | ------------------------------------------------------- |
1082
  | `t = v` | `T&` | `t` | `t` is equivalent to `v`, the value of `v` is unchanged |
1083
 
1084
 
1085
- [*Note 3*: Array types and non-object types are not
1086
- *Cpp17Destructible*. — *end note*]
 
 
 
 
 
1087
 
1088
  #### Swappable requirements <a id="swappable.requirements">[[swappable.requirements]]</a>
1089
 
1090
  This subclause provides definitions for swappable types and expressions.
1091
  In these definitions, let `t` denote an expression of type `T`, and let
@@ -1119,44 +1058,48 @@ swappable requirement includes the header `<utility>` to ensure an
1119
  appropriate evaluation context. — *end note*]
1120
 
1121
  An rvalue or lvalue `t` is *swappable* if and only if `t` is swappable
1122
  with any rvalue or lvalue, respectively, of type `T`.
1123
 
 
 
 
1124
  A type `X` meeting any of the iterator requirements
1125
  [[iterator.requirements]] meets the *Cpp17ValueSwappable* requirements
1126
  if, for any dereferenceable object `x` of type `X`, `*x` is swappable.
1127
 
1128
  [*Example 1*:
1129
 
1130
  User code can ensure that the evaluation of `swap` calls is performed in
1131
  an appropriate context under the various conditions as follows:
1132
 
1133
  ``` cpp
 
1134
  #include <utility>
1135
 
1136
- // Requires: std::forward<T>(t) shall be swappable with std::forward<U>(u).
1137
  template<class T, class U>
1138
  void value_swap(T&& t, U&& u) {
1139
  using std::swap;
1140
- swap(std::forward<T>(t), std::forward<U>(u)); // OK: uses ``swappable with'' conditions
1141
  // for rvalues and lvalues
1142
  }
1143
 
1144
- // Requires: lvalues of T shall be swappable.
1145
  template<class T>
1146
  void lv_swap(T& t1, T& t2) {
1147
  using std::swap;
1148
- swap(t1, t2); // OK: uses swappable conditions for lvalues of type T
1149
  }
1150
 
1151
  namespace N {
1152
  struct A { int m; };
1153
  struct Proxy { A* a; };
1154
  Proxy proxy(A& a) { return Proxy{ &a }; }
1155
 
1156
  void swap(A& x, Proxy p) {
1157
- std::swap(x.m, p.a->m); // OK: uses context equivalent to swappable
1158
  // conditions for fundamental types
1159
  }
1160
  void swap(Proxy p, A& x) { swap(x, p); } // satisfy symmetry constraint
1161
  }
1162
 
@@ -1177,22 +1120,21 @@ int main() {
1177
 
1178
  A *Cpp17NullablePointer* type is a pointer-like type that supports null
1179
  values. A type `P` meets the *Cpp17NullablePointer* requirements if:
1180
 
1181
  - `P` meets the *Cpp17EqualityComparable*, *Cpp17DefaultConstructible*,
1182
- *Cpp17CopyConstructible*, *Cpp17CopyAssignable*, and
1183
  *Cpp17Destructible* requirements,
1184
- - lvalues of type `P` are swappable [[swappable.requirements]],
1185
  - the expressions shown in [[cpp17.nullablepointer]] are valid and have
1186
  the indicated semantics, and
1187
  - `P` meets all the other requirements of this subclause.
1188
 
1189
  A value-initialized object of type `P` produces the null value of the
1190
  type. The null value shall be equivalent only to itself. A
1191
  default-initialized object of type `P` may have an indeterminate value.
1192
 
1193
- [*Note 1*: Operations involving indeterminate values may cause
1194
  undefined behavior. — *end note*]
1195
 
1196
  An object `p` of type `P` can be contextually converted to `bool`
1197
  [[conv]]. The effect shall be as if `p != nullptr` had been evaluated in
1198
  place of `p`.
@@ -1200,25 +1142,25 @@ place of `p`.
1200
  No operation which is part of the *Cpp17NullablePointer* requirements
1201
  shall exit via an exception.
1202
 
1203
  In [[cpp17.nullablepointer]], `u` denotes an identifier, `t` denotes a
1204
  non-`const` lvalue of type `P`, `a` and `b` denote values of type
1205
- (possibly `const`) `P`, and `np` denotes a value of type (possibly
1206
- `const`) `std::nullptr_t`.
1207
 
1208
  **Table: Cpp17NullablePointer requirements** <a id="cpp17.nullablepointer">[cpp17.nullablepointer]</a>
1209
 
1210
  | Expression | Return type | Operational semantics |
1211
- | -------------- | ---------------------------------- | --------------------------- |
1212
  | `P u(np);`<br> | | Ensures: `u == nullptr` |
1213
  | `P u = np;` | | |
1214
  | `P(np)` | | Ensures: `P(np) == nullptr` |
1215
  | `t = np` | `P&` | Ensures: `t == nullptr` |
1216
- | `a != b` | contextually convertible to `bool` | `!(a == b)` |
1217
- | `a == np` | contextually convertible to `bool` | `a == P()` |
1218
  | `np == a` | | |
1219
- | `a != np` | contextually convertible to `bool` | `!(a == np)` |
1220
  | `np != a` | | |
1221
 
1222
 
1223
  #### *Cpp17Hash* requirements <a id="hash.requirements">[[hash.requirements]]</a>
1224
 
@@ -1229,110 +1171,480 @@ A type `H` meets the requirements if:
1229
  and *Cpp17Destructible* ([[cpp17.destructible]]) requirements, and
1230
  - the expressions shown in [[cpp17.hash]] are valid and have the
1231
  indicated semantics.
1232
 
1233
  Given `Key` is an argument type for function objects of type `H`, in
1234
- [[cpp17.hash]] `h` is a value of type (possibly `const`) `H`, `u` is an
1235
  lvalue of type `Key`, and `k` is a value of a type convertible to
1236
- (possibly `const`) `Key`.
1237
 
1238
  [*Note 1*: Thus all evaluations of the expression `h(k)` with the same
1239
  value for `k` yield the same result for a given execution of the
1240
  program. — *end note*]
1241
 
1242
  #### *Cpp17Allocator* requirements <a id="allocator.requirements">[[allocator.requirements]]</a>
1243
 
 
 
1244
  The library describes a standard set of requirements for *allocators*,
1245
  which are class-type objects that encapsulate the information about an
1246
  allocation model. This information includes the knowledge of pointer
1247
  types, the type of their difference, the type of the size of objects in
1248
  this allocation model, as well as the memory allocation and deallocation
1249
  primitives for it. All of the string types [[strings]], containers
1250
  [[containers]] (except `array`), string buffers and string streams
1251
  [[input.output]], and `match_results` [[re]] are parameterized in terms
1252
  of allocators.
1253
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1254
  The class template `allocator_traits` [[allocator.traits]] supplies a
1255
- uniform interface to all allocator types. [[allocator.req.var]]
1256
- describes the types manipulated through allocators. [[cpp17.allocator]]
1257
- describes the requirements on allocator types and thus on types used to
1258
- instantiate `allocator_traits`. A requirement is optional if the last
1259
- column of [[cpp17.allocator]] specifies a default for a given
1260
- expression. Within the standard library `allocator_traits` template, an
1261
- optional requirement that is not supplied by an allocator is replaced by
1262
- the specified default expression. A user specialization of
1263
- `allocator_traits` may provide different defaults and may provide
1264
- defaults for different requirements than the primary template. Within
1265
- Tables  [[tab:allocator.req.var]] and  [[tab:cpp17.allocator]], the use
1266
- of `move` and `forward` always refers to `std::move` and `std::forward`,
1267
- respectively.
1268
-
1269
- [*Note 1*: If `n == 0`, the return value is unspecified. — *end note*]
1270
-
1271
- Note A: The member class template `rebind` in the table above is
1272
- effectively a typedef template.
1273
-
1274
- [*Note 2*: In general, if the name `Allocator` is bound to
1275
- `SomeAllocator<T>`, then `Allocator::rebind<U>::other` is the same type
1276
- as `SomeAllocator<U>`, where `SomeAllocator<T>::value_type` is `T` and
1277
- `SomeAllocator<U>::{}value_type` is `U`. — *end note*]
1278
-
1279
- If `Allocator` is a class template instantiation of the form
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1280
  `SomeAllocator<T, Args>`, where `Args` is zero or more type arguments,
1281
  and `Allocator` does not supply a `rebind` member template, the standard
1282
  `allocator_traits` template uses `SomeAllocator<U, Args>` in place of
1283
- `Allocator::{}rebind<U>::other` by default. For allocator types that are
1284
  not template instantiations of the above form, no default is provided.
1285
 
1286
- Note B: If `X::propagate_on_container_copy_assignment::value` is `true`,
1287
- `X` shall meet the *Cpp17CopyAssignable* requirements (
1288
- [[cpp17.copyassignable]]) and the copy operation shall not throw
1289
- exceptions. If `X::propagate_on_container_move_assignment::value` is
1290
- `true`, `X` shall meet the *Cpp17MoveAssignable* requirements (
1291
- [[cpp17.moveassignable]]) and the move operation shall not throw
1292
- exceptions. If `X::propagate_on_container_swap::value` is `true`,
1293
- lvalues of type `X` shall be swappable [[swappable.requirements]] and
1294
- the `swap` operation shall not throw exceptions.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1295
 
1296
  An allocator type `X` shall meet the *Cpp17CopyConstructible*
1297
- requirements ([[cpp17.copyconstructible]]). The `X::pointer`,
1298
- `X::const_pointer`, `X::void_pointer`, and `X::const_void_pointer` types
1299
- shall meet the *Cpp17NullablePointer* requirements (
1300
- [[cpp17.nullablepointer]]). No constructor, comparison function, copy
1301
- operation, move operation, or swap operation on these pointer types
1302
- shall exit via an exception. `X::pointer` and `X::const_pointer` shall
1303
- also meet the requirements for a *Cpp17RandomAccessIterator*
1304
- [[random.access.iterators]] and the additional requirement that, when
1305
- `a` and `(a + n)` are dereferenceable pointer values for some integral
1306
- value `n`,
1307
 
1308
  ``` cpp
1309
- addressof(*(a + n)) == addressof(*a) + n
1310
  ```
1311
 
1312
  is `true`.
1313
 
1314
  Let `x1` and `x2` denote objects of (possibly different) types
1315
- `X::void_pointer`, `X::const_void_pointer`, `X::pointer`, or
1316
- `X::const_pointer`. Then, `x1` and `x2` are *equivalently-valued*
1317
  pointer values, if and only if both `x1` and `x2` can be explicitly
1318
  converted to the two corresponding objects `px1` and `px2` of type
1319
- `X::const_pointer`, using a sequence of `static_cast`s using only these
1320
  four types, and the expression `px1 == px2` evaluates to `true`.
1321
 
1322
- Let `w1` and `w2` denote objects of type `X::void_pointer`. Then for the
1323
- expressions
1324
 
1325
  ``` cpp
1326
  w1 == w2
1327
  w1 != w2
1328
  ```
1329
 
1330
  either or both objects may be replaced by an equivalently-valued object
1331
- of type `X::const_void_pointer` with no change in semantics.
1332
 
1333
- Let `p1` and `p2` denote objects of type `X::pointer`. Then for the
1334
  expressions
1335
 
1336
  ``` cpp
1337
  p1 == p2
1338
  p1 != p2
@@ -1342,11 +1654,11 @@ p1 >= p2
1342
  p1 > p2
1343
  p1 - p2
1344
  ```
1345
 
1346
  either or both objects may be replaced by an equivalently-valued object
1347
- of type `X::const_pointer` with no change in semantics.
1348
 
1349
  An allocator may constrain the types on which it can be instantiated and
1350
  the arguments for which its `construct` or `destroy` members may be
1351
  called. If a type cannot be used with a particular allocator, the
1352
  allocator class or the call to `construct` or `destroy` may fail to
@@ -1355,34 +1667,32 @@ instantiate.
1355
  If the alignment associated with a specific over-aligned type is not
1356
  supported by an allocator, instantiation of the allocator for that type
1357
  may fail. The allocator also may silently ignore the requested
1358
  alignment.
1359
 
1360
- [*Note 3*: Additionally, the member function `allocate` for that type
1361
- may fail by throwing an object of type `bad_alloc`. — *end note*]
1362
 
1363
  [*Example 1*:
1364
 
1365
  The following is an allocator class template supporting the minimal
1366
- interface that meets the requirements of [[cpp17.allocator]]:
 
1367
 
1368
  ``` cpp
1369
- template<class Tp>
1370
  struct SimpleAllocator {
1371
- typedef Tp value_type;
1372
  SimpleAllocator(ctor args);
1373
 
1374
- template<class T> SimpleAllocator(const SimpleAllocator<T>& other);
1375
 
1376
- [[nodiscard]] Tp* allocate(std::size_t n);
1377
- void deallocate(Tp* p, std::size_t n);
 
 
1378
  };
1379
-
1380
- template<class T, class U>
1381
- bool operator==(const SimpleAllocator<T>&, const SimpleAllocator<U>&);
1382
- template<class T, class U>
1383
- bool operator!=(const SimpleAllocator<T>&, const SimpleAllocator<U>&);
1384
  ```
1385
 
1386
  — *end example*]
1387
 
1388
  ##### Allocator completeness requirements <a id="allocator.requirements.completeness">[[allocator.requirements.completeness]]</a>
@@ -1425,10 +1735,14 @@ library requirements for the original template.[^21]
1425
  The behavior of a C++ program is undefined if it declares an explicit or
1426
  partial specialization of any standard library variable template, except
1427
  where explicitly permitted by the specification of that variable
1428
  template.
1429
 
 
 
 
 
1430
  The behavior of a C++ program is undefined if it declares
1431
 
1432
  - an explicit specialization of any member function of a standard
1433
  library class template, or
1434
  - an explicit specialization of any member function template of a
@@ -1447,41 +1761,30 @@ standard library static member function, or an instantiation of a
1447
  standard library function template. Unless `F` is designated an
1448
  *addressable function*, the behavior of a C++ program is unspecified
1449
  (possibly ill-formed) if it explicitly or implicitly attempts to form a
1450
  pointer to `F`.
1451
 
1452
- [*Note 1*: Possible means of forming such pointers include application
1453
  of the unary `&` operator [[expr.unary.op]], `addressof`
1454
  [[specialized.addressof]], or a function-to-pointer standard conversion
1455
  [[conv.func]]. — *end note*]
1456
 
1457
  Moreover, the behavior of a C++ program is unspecified (possibly
1458
  ill-formed) if it attempts to form a reference to `F` or if it attempts
1459
  to form a pointer-to-member designating either a standard library
1460
  non-static member function [[member.functions]] or an instantiation of a
1461
  standard library member function template.
1462
 
1463
- Other than in namespace `std` or in a namespace within namespace `std`,
1464
- a program may provide an overload for any library function template
1465
- designated as a *customization point*, provided that (a) the overload’s
1466
- declaration depends on at least one user-defined type and (b) the
1467
- overload meets the standard library requirements for the customization
1468
- point. [^22]
1469
-
1470
- [*Note 2*: This permits a (qualified or unqualified) call to the
1471
- customization point to invoke the most appropriate overload for the
1472
- given arguments. — *end note*]
1473
-
1474
  A translation unit shall not declare namespace `std` to be an inline
1475
  namespace [[namespace.def]].
1476
 
1477
  ##### Namespace `posix` <a id="namespace.posix">[[namespace.posix]]</a>
1478
 
1479
  The behavior of a C++ program is undefined if it adds declarations or
1480
  definitions to namespace `posix` or to a namespace within namespace
1481
  `posix` unless otherwise specified. The namespace `posix` is reserved
1482
- for use by ISO/IEC 9945 and other POSIX standards.
1483
 
1484
  ##### Namespaces for future standardization <a id="namespace.future">[[namespace.future]]</a>
1485
 
1486
  Top-level namespaces whose *namespace-name* consists of `std` followed
1487
  by one or more *digit*s [[lex.name]] are reserved for future
@@ -1491,18 +1794,20 @@ declarations or definitions to such a namespace.
1491
  [*Example 1*: The top-level namespace `std2` is reserved for use by
1492
  future revisions of this International Standard. — *end example*]
1493
 
1494
  #### Reserved names <a id="reserved.names">[[reserved.names]]</a>
1495
 
 
 
1496
  The C++ standard library reserves the following kinds of names:
1497
 
1498
  - macros
1499
  - global names
1500
  - names with external linkage
1501
 
1502
  If a program declares or defines a name in a context where it is
1503
- reserved, other than as explicitly allowed by this Clause, its behavior
1504
  is undefined.
1505
 
1506
  ##### Zombie names <a id="zombie.names">[[zombie.names]]</a>
1507
 
1508
  In namespace `std`, the following names are reserved for previous
@@ -1518,10 +1823,13 @@ standardization:
1518
  - `binder2nd`,
1519
  - `const_mem_fun1_ref_t`,
1520
  - `const_mem_fun1_t`,
1521
  - `const_mem_fun_ref_t`,
1522
  - `const_mem_fun_t`,
 
 
 
1523
  - `get_temporary_buffer`,
1524
  - `get_unexpected`,
1525
  - `gets`,
1526
  - `is_literal_type`,
1527
  - `is_literal_type_v`,
@@ -1531,10 +1839,11 @@ standardization:
1531
  - `mem_fun_ref`,
1532
  - `mem_fun_t`,
1533
  - `mem_fun`,
1534
  - `not1`,
1535
  - `not2`,
 
1536
  - `pointer_to_binary_function`,
1537
  - `pointer_to_unary_function`,
1538
  - `ptr_fun`,
1539
  - `random_shuffle`,
1540
  - `raw_storage_iterator`,
@@ -1543,23 +1852,26 @@ standardization:
1543
  - `return_temporary_buffer`,
1544
  - `set_unexpected`,
1545
  - `unary_function`,
1546
  - `unary_negate`,
1547
  - `uncaught_exception`,
1548
- - `unexpected`, and
 
1549
  - `unexpected_handler`.
1550
 
1551
- The following names are reserved as member types for previous
1552
  standardization, and may not be used as a name for object-like macros in
1553
  portable code:
1554
 
1555
  - `argument_type`,
1556
  - `first_argument_type`,
1557
  - `io_state`,
1558
  - `open_mode`,
1559
- - `second_argument_type`, and
1560
- - `seek_dir`.
 
 
1561
 
1562
  The name `stossc` is reserved as a member function for previous
1563
  standardization, and may not be used as a name for function-like macros
1564
  in portable code.
1565
 
@@ -1579,36 +1891,40 @@ defined as function-like macros  [[cpp.replace]].
1579
 
1580
  ##### External linkage <a id="extern.names">[[extern.names]]</a>
1581
 
1582
  Each name declared as an object with external linkage in a header is
1583
  reserved to the implementation to designate that library object with
1584
- external linkage, [^23] both in namespace `std` and in the global
1585
- namespace.
 
1586
 
1587
  Each global function signature declared with external linkage in a
1588
  header is reserved to the implementation to designate that function
1589
- signature with external linkage.[^24]
1590
 
1591
  Each name from the C standard library declared with external linkage is
1592
  reserved to the implementation for use as a name with `extern "C"`
1593
  linkage, both in namespace `std` and in the global namespace.
1594
 
1595
  Each function signature from the C standard library declared with
1596
  external linkage is reserved to the implementation for use as a function
1597
- signature with both `extern "C"` and `extern "C++"` linkage,[^25] or as
1598
- a name of namespace scope in the global namespace.
 
1599
 
1600
  ##### Types <a id="extern.types">[[extern.types]]</a>
1601
 
1602
  For each type `T` from the C standard library, the types `::T` and
1603
  `std::T` are reserved to the implementation and, when defined, `::T`
1604
  shall be identical to `std::T`.
1605
 
1606
  ##### User-defined literal suffixes <a id="usrlit.suffix">[[usrlit.suffix]]</a>
1607
 
1608
  Literal suffix identifiers [[over.literal]] that do not start with an
1609
- underscore are reserved for future standardization.
 
 
1610
 
1611
  #### Headers <a id="alt.headers">[[alt.headers]]</a>
1612
 
1613
  If a file with a name equivalent to the derived file name for one of the
1614
  C++ standard library headers is not provided as part of the
@@ -1625,15 +1941,15 @@ program [[class.virtual]].
1625
  #### Replacement functions <a id="replacement.functions">[[replacement.functions]]</a>
1626
 
1627
  [[support]] through [[thread]] and [[depr]] describe the behavior of
1628
  numerous functions defined by the C++ standard library. Under some
1629
  circumstances, however, certain of these function descriptions also
1630
- apply to replacement functions defined in the program [[definitions]].
1631
 
1632
  A C++ program may provide the definition for any of the following
1633
- dynamic memory allocation function signatures declared in header
1634
- `<new>` ([[basic.stc.dynamic]], [[new.syn]]):
1635
 
1636
  ``` cpp
1637
  operator new(std::size_t)
1638
  operator new(std::size_t, std::align_val_t)
1639
  operator new(std::size_t, const std::nothrow_t&)
@@ -1665,11 +1981,11 @@ operator delete[](void*, const std::nothrow_t&)
1665
  operator delete[](void*, std::align_val_t, const std::nothrow_t&)
1666
  ```
1667
 
1668
  The program’s definitions are used instead of the default versions
1669
  supplied by the implementation [[new.delete]]. Such replacement occurs
1670
- prior to program startup ([[basic.def.odr]], [[basic.start]]). The
1671
  program’s declarations shall not be specified as `inline`. No diagnostic
1672
  is required.
1673
 
1674
  #### Handler functions <a id="handler.functions">[[handler.functions]]</a>
1675
 
@@ -1705,31 +2021,30 @@ In certain cases (replacement functions, handler functions, operations
1705
  on types used to instantiate standard library template components), the
1706
  C++ standard library depends on components supplied by a C++ program. If
1707
  these components do not meet their requirements, this document places no
1708
  requirements on the implementation.
1709
 
1710
- In particular, the effects are undefined in the following cases:
1711
 
1712
  - For replacement functions [[new.delete]], if the installed replacement
1713
  function does not implement the semantics of the applicable *Required
1714
  behavior:* paragraph.
1715
- - For handler functions ([[new.handler]], [[terminate.handler]]), if
1716
- the installed handler function does not implement the semantics of the
1717
  applicable *Required behavior:* paragraph.
1718
  - For types used as template arguments when instantiating a template
1719
  component, if the operations on the type do not implement the
1720
- semantics of the applicable *Requirements* subclause (
1721
- [[allocator.requirements]], [[container.requirements]],
1722
- [[iterator.requirements]], [[algorithms.requirements]],
1723
- [[numeric.requirements]]). Operations on such types can report a
1724
- failure by throwing an exception unless otherwise specified.
1725
  - If any replacement function or handler function or destructor
1726
  operation exits via an exception, unless specifically allowed in the
1727
  applicable *Required behavior:* paragraph.
1728
- - If an incomplete type [[basic.types]] is used as a template argument
1729
- when instantiating a template component or evaluating a concept,
1730
- unless specifically allowed for that component.
1731
 
1732
  #### Function arguments <a id="res.on.arguments">[[res.on.arguments]]</a>
1733
 
1734
  Each of the following applies to all arguments to functions defined in
1735
  the C++ standard library, unless explicitly stated otherwise.
@@ -1740,22 +2055,23 @@ the C++ standard library, unless explicitly stated otherwise.
1740
  - If a function argument is described as being an array, the pointer
1741
  actually passed to the function shall have a value such that all
1742
  address computations and accesses to objects (that would be valid if
1743
  the pointer did point to the first element of such an array) are in
1744
  fact valid.
1745
- - If a function argument binds to an rvalue reference parameter, the
1746
  implementation may assume that this parameter is a unique reference to
1747
- this argument. \[*Note 1*: If the parameter is a generic parameter of
1748
- the form `T&&` and an lvalue of type `A` is bound, the argument binds
1749
- to an lvalue reference [[temp.deduct.call]] and thus is not covered by
1750
- the previous sentence. *end note*] \[*Note 2*: If a program casts
1751
- an lvalue to an xvalue while passing that lvalue to a library function
1752
- (e.g., by calling the function with the argument `std::move(x)`), the
1753
- program is effectively asking that function to treat that lvalue as a
1754
- temporary object. The implementation is free to optimize away aliasing
1755
- checks which might be needed if the argument was an
1756
- lvalue. *end note*]
 
1757
 
1758
  #### Library object access <a id="res.on.objects">[[res.on.objects]]</a>
1759
 
1760
  The behavior of a program is undefined if calls to standard library
1761
  functions from different threads may introduce a data race. The
@@ -1773,15 +2089,10 @@ access, or the access does not happen before the end of the object’s
1773
  lifetime, the behavior is undefined unless otherwise specified.
1774
 
1775
  [*Note 2*: This applies even to objects such as mutexes intended for
1776
  thread synchronization. — *end note*]
1777
 
1778
- #### Expects paragraph <a id="res.on.expects">[[res.on.expects]]</a>
1779
-
1780
- Violation of any preconditions specified in a function’s
1781
- *Preconditions:* element results in undefined behavior.
1782
-
1783
  #### Semantic requirements <a id="res.on.requirements">[[res.on.requirements]]</a>
1784
 
1785
  A sequence `Args` of template arguments is said to *model* a concept `C`
1786
  if `Args` satisfies `C` [[temp.constr.decl]] and meets all semantic
1787
  requirements (if any) given in the specification of `C`.
@@ -1818,11 +2129,11 @@ those other headers.
1818
 
1819
  Certain types and macros are defined in more than one header. Every such
1820
  entity shall be defined such that any header that defines it may be
1821
  included after any other header that also defines it [[basic.def.odr]].
1822
 
1823
- The C standard library headers [[depr.c.headers]] shall include only
1824
  their corresponding C++ standard library header, as described in 
1825
  [[headers]].
1826
 
1827
  #### Restrictions on macro definitions <a id="res.on.macro.definitions">[[res.on.macro.definitions]]</a>
1828
 
@@ -1839,11 +2150,11 @@ stated otherwise.
1839
  It is unspecified whether any non-member functions in the C++ standard
1840
  library are defined as inline [[dcl.inline]].
1841
 
1842
  A call to a non-member function signature described in [[support]]
1843
  through [[thread]] and [[depr]] shall behave as if the implementation
1844
- declared no additional non-member function signatures.[^26]
1845
 
1846
  An implementation shall not declare a non-member function signature with
1847
  additional default arguments.
1848
 
1849
  Unless otherwise specified, calls made by functions in the standard
@@ -1878,11 +2189,11 @@ For a non-virtual member function described in the C++ standard library,
1878
  an implementation may declare a different set of member function
1879
  signatures, provided that any call to the member function that would
1880
  select an overload from the set of declarations described in this
1881
  document behaves as if that overload were selected.
1882
 
1883
- [*Note 1*: For instance, an implementation may add parameters with
1884
  default values, or replace a member function with default arguments with
1885
  two or more member functions with equivalent behavior, or add additional
1886
  signatures for a member function name. — *end note*]
1887
 
1888
  #### Friend functions <a id="hidden.friends">[[hidden.friends]]</a>
@@ -1948,12 +2259,12 @@ objects [[intro.multithread]] accessible by threads other than the
1948
  current thread unless the objects are accessed directly or indirectly
1949
  via the function’s non-const arguments, including `this`.
1950
 
1951
  [*Note 1*: This means, for example, that implementations can’t use an
1952
  object with static storage duration for internal purposes without
1953
- synchronization because it could cause a data race even in programs that
1954
- do not explicitly share objects between threads. — *end note*]
1955
 
1956
  A C++ standard library function shall not access objects indirectly
1957
  accessible via its arguments or via elements of its container arguments
1958
  except by invoking functions required by its specification on those
1959
  container elements.
@@ -1997,11 +2308,14 @@ the implementation.
1997
  In any case:
1998
 
1999
  - Every base class described as `virtual` shall be virtual;
2000
  - Every base class not specified as `virtual` shall not be virtual;
2001
  - Unless explicitly stated otherwise, types with distinct names shall be
2002
- distinct types.[^27]
 
 
 
2003
 
2004
  All types specified in the C++ standard library shall be non-`final`
2005
  types unless otherwise specified.
2006
 
2007
  #### Restrictions on exception handling <a id="res.on.exception.handling">[[res.on.exception.handling]]</a>
@@ -2010,41 +2324,30 @@ Any of the functions defined in the C++ standard library can report a
2010
  failure by throwing an exception of a type described in its *Throws:*
2011
  paragraph, or of a type derived from a type named in the *Throws:*
2012
  paragraph that would be caught by an exception handler for the base
2013
  type.
2014
 
2015
- Functions from the C standard library shall not throw exceptions [^28]
 
2016
  except when such a function calls a program-supplied function that
2017
- throws an exception.[^29]
2018
 
2019
  Destructor operations defined in the C++ standard library shall not
2020
  throw exceptions. Every destructor in the C++ standard library shall
2021
  behave as if it had a non-throwing exception specification.
2022
 
2023
  Functions defined in the C++ standard library that do not have a
2024
  *Throws:* paragraph but do have a potentially-throwing exception
2025
- specification may throw *implementation-defined* exceptions. [^30]
 
2026
  Implementations should report errors by throwing exceptions of or
2027
- derived from the standard exception classes ([[bad.alloc]],
2028
- [[support.exception]], [[std.exceptions]]).
2029
 
2030
  An implementation may strengthen the exception specification for a
2031
  non-virtual function by adding a non-throwing exception specification.
2032
 
2033
- #### Restrictions on storage of pointers <a id="res.on.pointer.storage">[[res.on.pointer.storage]]</a>
2034
-
2035
- Objects constructed by the standard library that may hold a
2036
- user-supplied pointer value or an integer of type `std::intptr_t` shall
2037
- store such values in a traceable pointer location
2038
- [[basic.stc.dynamic.safety]].
2039
-
2040
- [*Note 1*: Other libraries are strongly encouraged to do the same,
2041
- since not doing so may result in accidental use of pointers that are not
2042
- safely derived. Libraries that store pointers outside the user’s address
2043
- space should make it appear that they are stored and retrieved from a
2044
- traceable pointer location. — *end note*]
2045
-
2046
  #### Value of error codes <a id="value.error.codes">[[value.error.codes]]</a>
2047
 
2048
  Certain functions in the C++ standard library report errors via a
2049
  `std::error_code` [[syserr.errcode.overview]] object. That object’s
2050
  `category()` member shall return `std::system_category()` for errors
@@ -2067,25 +2370,29 @@ associated values. — *end example*]
2067
  Objects of types defined in the C++ standard library may be moved from
2068
  [[class.copy.ctor]]. Move operations may be explicitly specified or
2069
  implicitly generated. Unless otherwise specified, such moved-from
2070
  objects shall be placed in a valid but unspecified state.
2071
 
 
 
 
 
 
2072
  <!-- Link reference definitions -->
2073
  [alg.c.library]: algorithms.md#alg.c.library
2074
  [alg.sorting]: algorithms.md#alg.sorting
2075
  [algorithm.stable]: #algorithm.stable
2076
  [algorithms]: algorithms.md#algorithms
2077
  [algorithms.requirements]: algorithms.md#algorithms.requirements
2078
  [alloc.errors]: support.md#alloc.errors
2079
- [allocator.req.var]: #allocator.req.var
2080
  [allocator.requirements]: #allocator.requirements
2081
  [allocator.requirements.completeness]: #allocator.requirements.completeness
2082
- [allocator.traits]: utilities.md#allocator.traits
 
2083
  [alt.headers]: #alt.headers
2084
- [atomics]: atomics.md#atomics
2085
- [atomics.alias]: atomics.md#atomics.alias
2086
- [atomics.lockfree]: atomics.md#atomics.lockfree
2087
  [bad.alloc]: support.md#bad.alloc
2088
  [basic.def.odr]: basic.md#basic.def.odr
2089
  [basic.fundamental]: basic.md#basic.fundamental
2090
  [basic.life]: basic.md#basic.life
2091
  [basic.link]: basic.md#basic.link
@@ -2093,24 +2400,24 @@ objects shall be placed in a valid but unspecified state.
2093
  [basic.lookup.qual]: basic.md#basic.lookup.qual
2094
  [basic.lookup.unqual]: basic.md#basic.lookup.unqual
2095
  [basic.scope.namespace]: basic.md#basic.scope.namespace
2096
  [basic.start]: basic.md#basic.start
2097
  [basic.stc.dynamic]: basic.md#basic.stc.dynamic
2098
- [basic.stc.dynamic.safety]: basic.md#basic.stc.dynamic.safety
2099
- [basic.types]: basic.md#basic.types
2100
- [bit]: numerics.md#bit
2101
  [bitmask.types]: #bitmask.types
2102
  [byte.strings]: #byte.strings
2103
  [c.annex.k.names]: #c.annex.k.names
 
 
2104
  [character.seq]: #character.seq
 
2105
  [class.copy.assign]: class.md#class.copy.assign
2106
  [class.copy.ctor]: class.md#class.copy.ctor
2107
  [class.dtor]: class.md#class.dtor
2108
  [class.mem]: class.md#class.mem
2109
- [class.mfct]: class.md#class.mfct
2110
- [class.this]: class.md#class.this
2111
  [class.virtual]: class.md#class.virtual
 
2112
  [cmp]: support.md#cmp
2113
  [compliance]: #compliance
2114
  [concept.destructible]: concepts.md#concept.destructible
2115
  [concept.invocable]: concepts.md#concept.invocable
2116
  [concept.totallyordered]: concepts.md#concept.totallyordered
@@ -2126,52 +2433,48 @@ objects shall be placed in a valid but unspecified state.
2126
  [containers]: containers.md#containers
2127
  [contents]: #contents
2128
  [conv]: expr.md#conv
2129
  [conv.func]: expr.md#conv.func
2130
  [conventions]: #conventions
 
2131
  [cpp.include]: cpp.md#cpp.include
2132
  [cpp.replace]: cpp.md#cpp.replace
2133
- [cpp17.allocator]: #cpp17.allocator
2134
  [cpp17.copyassignable]: #cpp17.copyassignable
2135
  [cpp17.copyconstructible]: #cpp17.copyconstructible
2136
  [cpp17.destructible]: #cpp17.destructible
2137
  [cpp17.hash]: #cpp17.hash
2138
  [cpp17.moveassignable]: #cpp17.moveassignable
2139
  [cpp17.nullablepointer]: #cpp17.nullablepointer
2140
- [cstdint]: support.md#cstdint
 
 
2141
  [customization.point.object]: #customization.point.object
2142
  [dcl.array]: dcl.md#dcl.array
2143
  [dcl.attr]: dcl.md#dcl.attr
2144
  [dcl.constexpr]: dcl.md#dcl.constexpr
2145
  [dcl.fct.default]: dcl.md#dcl.fct.default
2146
  [dcl.init]: dcl.md#dcl.init
2147
- [dcl.init.list]: dcl.md#dcl.init.list
2148
  [dcl.inline]: dcl.md#dcl.inline
2149
  [dcl.link]: dcl.md#dcl.link
2150
  [dcl.pre]: dcl.md#dcl.pre
2151
- [definitions]: #definitions
 
2152
  [depr]: future.md#depr
2153
- [depr.c.headers]: future.md#depr.c.headers
2154
  [derivation]: #derivation
2155
  [derived.classes]: #derived.classes
2156
  [description]: #description
 
2157
  [diagnostics]: diagnostics.md#diagnostics
2158
  [enumerated.types]: #enumerated.types
2159
  [except]: except.md#except
2160
- [except.spec]: except.md#except.spec
2161
- [expos.only.func]: #expos.only.func
2162
- [expos.only.types]: #expos.only.types
2163
- [expr.cond]: expr.md#expr.cond
2164
- [expr.const]: expr.md#expr.const
2165
  [expr.delete]: expr.md#expr.delete
2166
- [expr.eq]: expr.md#expr.eq
2167
  [expr.new]: expr.md#expr.new
2168
- [expr.rel]: expr.md#expr.rel
2169
- [expr.spaceship]: expr.md#expr.spaceship
2170
  [expr.unary.op]: expr.md#expr.unary.op
2171
  [extern.names]: #extern.names
2172
  [extern.types]: #extern.types
 
2173
  [function.objects]: utilities.md#function.objects
2174
  [functions.within.classes]: #functions.within.classes
2175
  [global.functions]: #global.functions
2176
  [handler.functions]: #handler.functions
2177
  [hash.requirements]: #hash.requirements
@@ -2180,16 +2483,15 @@ objects shall be placed in a valid but unspecified state.
2180
  [headers.cpp.c]: #headers.cpp.c
2181
  [headers.cpp.fs]: #headers.cpp.fs
2182
  [hidden.friends]: #hidden.friends
2183
  [input.output]: input.md#input.output
2184
  [intro.compliance]: intro.md#intro.compliance
2185
- [intro.defs]: intro.md#intro.defs
2186
- [intro.execution]: basic.md#intro.execution
2187
  [intro.multithread]: basic.md#intro.multithread
2188
  [intro.refs]: intro.md#intro.refs
2189
  [iterator.requirements]: iterators.md#iterator.requirements
2190
  [iterators]: iterators.md#iterators
 
2191
  [lex.name]: lex.md#lex.name
2192
  [lex.name.special]: #lex.name.special
2193
  [lex.phases]: lex.md#lex.phases
2194
  [lex.separate]: lex.md#lex.separate
2195
  [lib.types.movedfrom]: #lib.types.movedfrom
@@ -2198,12 +2500,14 @@ objects shall be placed in a valid but unspecified state.
2198
  [library.categories]: #library.categories
2199
  [library.general]: #library.general
2200
  [locales]: localization.md#locales
2201
  [localization]: localization.md#localization
2202
  [macro.names]: #macro.names
 
2203
  [member.functions]: #member.functions
2204
- [meta]: utilities.md#meta
 
2205
  [module.import]: module.md#module.import
2206
  [multibyte.strings]: #multibyte.strings
2207
  [namespace.constraints]: #namespace.constraints
2208
  [namespace.def]: dcl.md#namespace.def
2209
  [namespace.future]: #namespace.future
@@ -2216,44 +2520,49 @@ objects shall be placed in a valid but unspecified state.
2216
  [nullablepointer.requirements]: #nullablepointer.requirements
2217
  [numeric.requirements]: numerics.md#numeric.requirements
2218
  [numerics]: numerics.md#numerics
2219
  [objects.within.classes]: #objects.within.classes
2220
  [organization]: #organization
 
2221
  [ostream.iterator.ops]: iterators.md#ostream.iterator.ops
2222
  [over.literal]: over.md#over.literal
2223
  [over.match]: over.md#over.match
2224
- [over.oper]: over.md#over.oper
2225
  [protection.within.classes]: #protection.within.classes
2226
  [random.access.iterators]: iterators.md#random.access.iterators
2227
  [ranges]: ranges.md#ranges
 
2228
  [re]: re.md#re
2229
  [reentrancy]: #reentrancy
2230
  [replacement.functions]: #replacement.functions
2231
  [requirements]: #requirements
 
2232
  [res.on.arguments]: #res.on.arguments
2233
  [res.on.data.races]: #res.on.data.races
2234
  [res.on.exception.handling]: #res.on.exception.handling
2235
- [res.on.expects]: #res.on.expects
2236
  [res.on.functions]: #res.on.functions
2237
  [res.on.headers]: #res.on.headers
2238
  [res.on.macro.definitions]: #res.on.macro.definitions
2239
  [res.on.objects]: #res.on.objects
2240
- [res.on.pointer.storage]: #res.on.pointer.storage
2241
  [res.on.requirements]: #res.on.requirements
2242
  [reserved.names]: #reserved.names
2243
- [specialized.addressof]: utilities.md#specialized.addressof
 
2244
  [std.exceptions]: diagnostics.md#std.exceptions
 
2245
  [stmt.return]: stmt.md#stmt.return
2246
  [stream.types]: input.md#stream.types
2247
  [strings]: strings.md#strings
2248
  [structure]: #structure
2249
  [structure.elements]: #structure.elements
2250
  [structure.requirements]: #structure.requirements
2251
  [structure.see.also]: #structure.see.also
2252
  [structure.specifications]: #structure.specifications
2253
  [structure.summary]: #structure.summary
2254
  [support]: support.md#support
 
 
2255
  [support.coroutine]: support.md#support.coroutine
2256
  [support.dynamic]: support.md#support.dynamic
2257
  [support.exception]: support.md#support.exception
2258
  [support.initlist]: support.md#support.initlist
2259
  [support.limits]: support.md#support.limits
@@ -2263,90 +2572,93 @@ objects shall be placed in a valid but unspecified state.
2263
  [support.start.term]: support.md#support.start.term
2264
  [support.types]: support.md#support.types
2265
  [swappable.requirements]: #swappable.requirements
2266
  [syserr]: diagnostics.md#syserr
2267
  [syserr.errcode.overview]: diagnostics.md#syserr.errcode.overview
2268
- [tab:allocator.req.var]: #tab:allocator.req.var
2269
- [tab:cpp17.allocator]: #tab:cpp17.allocator
2270
  [tab:cpp17.destructible]: #tab:cpp17.destructible
2271
  [tab:cpp17.equalitycomparable]: #tab:cpp17.equalitycomparable
2272
  [temp]: temp.md#temp
2273
  [temp.concept]: temp.md#temp.concept
2274
  [temp.constr.decl]: temp.md#temp.constr.decl
2275
- [temp.constr.order]: temp.md#temp.constr.order
2276
  [temp.deduct.call]: temp.md#temp.deduct.call
2277
- [temp.func.order]: temp.md#temp.func.order
2278
  [template.bitset]: utilities.md#template.bitset
 
 
2279
  [terminate.handler]: support.md#terminate.handler
2280
  [thread]: thread.md#thread
2281
  [time]: time.md#time
 
2282
  [type.descriptions]: #type.descriptions
2283
  [type.descriptions.general]: #type.descriptions.general
 
2284
  [using]: #using
2285
  [using.headers]: #using.headers
2286
  [using.linkage]: #using.linkage
2287
  [using.overview]: #using.overview
2288
  [usrlit.suffix]: #usrlit.suffix
2289
  [utilities]: utilities.md#utilities
 
2290
  [utility.arg.requirements]: #utility.arg.requirements
2291
  [utility.requirements]: #utility.requirements
 
2292
  [value.error.codes]: #value.error.codes
2293
  [zombie.names]: #zombie.names
2294
 
2295
- [^1]: To save space, items that do not apply to a Clause are omitted.
 
 
2296
  For example, if a Clause does not specify any requirements, there
2297
  will be no “Requirements” subclause.
2298
 
2299
- [^2]: Although in some cases the code given is unambiguously the optimum
2300
  implementation.
2301
 
2302
- [^3]: To save space, items that do not apply to a class are omitted. For
2303
- example, if a class does not specify any comparison functions, there
2304
- will be no “Comparison functions” subclause.
 
2305
 
2306
- [^4]: To save space, elements that do not apply to a function are
2307
  omitted. For example, if a function specifies no preconditions,
2308
  there will be no *Preconditions:* element.
2309
 
2310
- [^5]: This simplifies the presentation of complexity requirements in
2311
  some cases.
2312
 
2313
- [^6]: Examples from  [[utility.requirements]] include:
2314
  *Cpp17EqualityComparable*, *Cpp17LessThanComparable*,
2315
  *Cpp17CopyConstructible*. Examples from  [[iterator.requirements]]
2316
  include: *Cpp17InputIterator*, *Cpp17ForwardIterator*.
2317
 
2318
- [^7]: Such as an integer type, with constant integer values
2319
  [[basic.fundamental]].
2320
 
2321
- [^8]: declared in `<clocale>`.
2322
-
2323
  [^9]: Many of the objects manipulated by function signatures declared in
2324
  `<cstring>` are character sequences or NTBSs. The size of some of
2325
  these character sequences is limited by a length value, maintained
2326
  separately from the character sequence.
2327
 
2328
  [^10]: A *string-literal*, such as `"abc"`, is a static NTBS.
2329
 
2330
- [^11]: An NTBS that contains characters only from the basic execution
2331
  character set is also an NTMBS. Each multibyte character then
2332
  consists of a single byte.
2333
 
2334
- [^12]: The C standard library headers [[depr.c.headers]] also define
2335
  names within the global namespace, while the C++ headers for C
2336
- library facilities [[headers]] may also define names within the
2337
  global namespace.
2338
 
2339
  [^13]: This gives implementers freedom to use inline namespaces to
2340
  support multiple configurations of the library.
2341
 
2342
  [^14]: A header is not necessarily a source file, nor are the sequences
2343
  delimited by `<` and `>` in header names necessarily valid source
2344
  file names [[cpp.include]].
2345
 
2346
  [^15]: It is intentional that there is no C++ header for any of these C
2347
- headers: `<stdatomic.h>`, `<stdnoreturn.h>`, `<threads.h>`.
2348
 
2349
  [^16]: This disallows the practice, allowed in C, of providing a masking
2350
  macro in addition to the function prototype. The only way to achieve
2351
  equivalent inline behavior in C++ is to provide a definition as an
2352
  extern inline function.
@@ -2368,48 +2680,33 @@ objects shall be placed in a valid but unspecified state.
2368
 
2369
  [^21]: Any library code that instantiates other library templates must
2370
  be prepared to work adequately with any user-supplied specialization
2371
  that meets the minimum requirements of this document.
2372
 
2373
- [^22]: Any library customization point must be prepared to work
2374
- adequately with any user-defined overload that meets the minimum
2375
- requirements of this document. Therefore an implementation may
2376
- elect, under the as-if rule [[intro.execution]], to provide any
2377
- customization point in the form of an instantiated function object
2378
- [[function.objects]] even though the customization point’s
2379
- specification is in the form of a function template. The template
2380
- parameters of each such function object and the function parameters
2381
- and return type of the object’s `operator()` must match those of the
2382
- corresponding customization point’s specification.
2383
-
2384
- [^23]: The list of such reserved names includes `errno`, declared or
2385
  defined in `<cerrno>`.
2386
 
2387
- [^24]: The list of such reserved function signatures with external
2388
  linkage includes `setjmp(jmp_buf)`, declared or defined in
2389
  `<csetjmp>`, and `va_end(va_list)`, declared or defined in
2390
  `<cstdarg>`.
2391
 
2392
- [^25]: The function signatures declared in `<cuchar>`, `<cwchar>`, and
2393
  `<cwctype>` are always reserved, notwithstanding the restrictions
2394
  imposed in subclause 4.5.1 of Amendment 1 to the C Standard for
2395
  these headers.
2396
 
2397
- [^26]: A valid C++ program always calls the expected library non-member
2398
- function. An implementation may also define additional non-member
2399
  functions that would otherwise not be called by a valid C++ program.
2400
 
2401
- [^27]: There is an implicit exception to this rule for types that are
2402
- described as synonyms for basic integral types, such as `size_t`
2403
- [[support.types]] and `streamoff` [[stream.types]].
2404
-
2405
- [^28]: That is, the C library functions can all be treated as if they
2406
  are marked `noexcept`. This allows implementations to make
2407
  performance optimizations based on the absence of exceptions at
2408
  runtime.
2409
 
2410
- [^29]: The functions `qsort()` and `bsearch()` [[alg.c.library]] meet
2411
  this condition.
2412
 
2413
- [^30]: In particular, they can report a failure to allocate storage by
2414
  throwing an exception of type `bad_alloc`, or a class derived from
2415
  `bad_alloc` [[bad.alloc]].
 
4
 
5
  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>
 
21
  | Clause | Category |
22
  | ---------------- | --------------------------- |
23
  | [[support]] | Language support library |
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 |
 
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++
47
  programs may use to perform compile-time validation of template
48
  arguments and perform function dispatch based on properties of types.
49
 
50
  The diagnostics library [[diagnostics]] provides a consistent framework
51
  for reporting errors in a C++ program, including predefined exception
52
  classes.
53
 
54
+ The memory management library [[mem]] provides components for memory
55
+ management, including smart pointers and scoped allocators.
56
+
57
+ The metaprogramming library [[meta]] describes facilities for use in
58
+ templates and during constant evaluation, including type traits, integer
59
+ sequences, and rational arithmetic.
60
+
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
 
 
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.
 
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
 
130
  ## Method of description <a id="description">[[description]]</a>
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>
142
 
143
+ Each library clause contains the following elements, as applicable:[^2]
144
 
145
  - Summary
146
  - Requirements
147
  - Detailed specifications
148
  - References to the C standard library
 
207
  [[type.descriptions]].
208
 
209
  In some cases the semantic requirements are presented as C++ code. Such
210
  code is intended as a specification of equivalence of a construct to
211
  another construct, not necessarily as the way the construct must be
212
+ implemented.[^3]
213
 
214
  Required operations of any concept defined in this document need not be
215
  total functions; that is, some arguments to a required operation may
216
  result in the required semantics failing to be met.
217
 
 
235
  - restrictions on template arguments, if any
236
  - description of class invariants
237
  - description of function semantics
238
 
239
  Descriptions of class member functions follow the order (as
240
+ appropriate):[^4]
241
 
242
  - constructor(s) and destructor
243
  - copying, moving & assignment functions
244
+ - comparison operator functions
245
  - modifier functions
246
  - observer functions
247
  - operators and other non-member functions
248
 
249
  Descriptions of function semantics contain the following elements (as
250
+ appropriate):[^5]
251
 
252
  - *Constraints:* the conditions for the function’s participation in
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.
 
307
  describes the semantics of a function definition provided by either the
308
  implementation or a C++ program. Where no distinction is explicitly made
309
  in the description, the behavior described is the required behavior.
310
 
311
  If the formulation of a complexity requirement calls for a negative
312
+ number of operations, the actual requirement is zero operations.[^6]
313
 
314
  Complexity requirements specified in the library clauses are upper
315
  bounds, and implementations that provide better complexity guarantees
316
  meet the requirements.
317
 
 
325
  cross-references to the relevant portions of other standards
326
  [[intro.refs]].
327
 
328
  ### Other conventions <a id="conventions">[[conventions]]</a>
329
 
330
+ #### General <a id="conventions.general">[[conventions.general]]</a>
 
 
 
331
 
332
+ Subclause [[conventions]] describes several editorial conventions used
333
+ 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)
 
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
381
+ constraints on template arguments.[^7]
382
+
383
+ These names are used in library Clauses to describe the types that may
384
+ be supplied as arguments by a C++ program when instantiating template
385
+ components from the library.
386
 
387
  Certain types defined in [[input.output]] are used to describe
388
  implementation-defined types. They are based on other types, but with
389
  added constraints.
390
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
391
  ##### Enumerated types <a id="enumerated.types">[[enumerated.types]]</a>
392
 
393
  Several types defined in [[input.output]] are *enumerated types*. Each
394
  enumerated type may be implemented as an enumeration or as a synonym for
395
+ an enumeration.[^8]
396
 
397
  The enumerated type `enumerated` can be written:
398
 
399
  ``` cpp
400
  enum enumerated { V₀, V₁, V₂, V₃, … };
 
472
  - The value *Y* *is set* in the object *X* if the expression *X* `&` *Y*
473
  is nonzero.
474
 
475
  ##### Character sequences <a id="character.seq">[[character.seq]]</a>
476
 
477
+ ###### General <a id="character.seq.general">[[character.seq.general]]</a>
478
+
479
  The C standard library makes widespread use of characters and character
480
  sequences that follow a few uniform conventions:
481
 
482
+ - Properties specified as *locale-specific* may change during program
483
+ execution by a call to `setlocale(int, const char*)` [[clocale.syn]],
484
+ or by a change to a `locale` object, as described in [[locales]] and
485
+ [[input.output]].
486
+ - The *execution character set* and the *execution wide-character set*
487
+ are supersets of the basic literal character set [[lex.charset]]. The
488
+ encodings of the execution character sets and the sets of additional
489
+ elements (if any) are locale-specific. Each element of the execution
490
+ wide-character set is encoded as a single code unit representable by a
491
+ value of type `wchar_t`. \[*Note 1*: The encodings of the execution
492
+ character sets can be unrelated to any literal
493
+ encoding. — *end note*]
494
  - A *letter* is any of the 26 lowercase or 26 uppercase letters in the
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
 
523
 
524
  A *static NTBS* is an NTBS with static storage duration.[^10]
525
 
526
  ###### Multibyte strings <a id="multibyte.strings">[[multibyte.strings]]</a>
527
 
528
+ A *multibyte character* is a sequence of one or more bytes representing
529
+ the code unit sequence for an encoded character of the execution
530
+ character set.
531
+
532
  A *null-terminated multibyte string*, or NTMBS, is an NTBS that
533
  constitutes a sequence of valid multibyte characters, beginning and
534
  ending in the initial shift state.[^11]
535
 
536
  A *static NTMBS* is an NTMBS with static storage duration.
 
543
 
544
  The type of a customization point object, ignoring cv-qualifiers, shall
545
  model `semiregular` [[concepts.object]].
546
 
547
  All instances of a specific customization point object type shall be
548
+ equal [[concepts.equality]]. The effects of invoking different instances
549
+ of a specific customization point object type on the same arguments are
550
+ equivalent.
551
 
552
+ The type `T` of a customization point object, ignoring *cv-qualifier*s,
553
+ shall model `invocable<T&, Args...>`, `invocable<const T&, Args...>`,
554
+ `invocable<T, Args...>`, and `invocable<const T, Args...>`
555
+ [[concept.invocable]] when the types in `Args...` meet the requirements
556
+ specified in that customization point object’s definition. When the
557
+ types of `Args...` do not meet the customization point object’s
558
+ requirements, `T` shall not have a function call operator that
559
+ participates in overload resolution.
560
+
561
+ For a given customization point object `o`, let `p` be a variable
562
+ initialized as if by `auto p = o;`. Then for any sequence of arguments
563
+ `args...`, the following expressions have effects equivalent to
564
+ `o(args...)`:
565
+
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
 
602
  ```
603
 
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
 
673
+ [[organization]] describes the library’s contents and organization,
674
+ [[using]] describes how well-formed C++ programs gain access to library
675
+ entities, [[utility.requirements]] describes constraints on types and
676
+ functions used with the C++ standard library, [[constraints]] describes
677
+ constraints on well-formed C++ programs, and [[conforming]] describes
678
+ constraints on conforming implementations.
679
 
680
  ### Library contents and organization <a id="organization">[[organization]]</a>
681
 
682
+ #### General <a id="organization.general">[[organization.general]]</a>
683
+
684
  [[contents]] describes the entities and macros defined in the C++
685
  standard library. [[headers]] lists the standard library headers and
686
  some constraints on those headers. [[compliance]] lists requirements for
687
  a freestanding implementation of the C++ standard library.
688
 
 
692
  macros described in the synopses of the C++ standard library headers
693
  [[headers]], unless otherwise specified.
694
 
695
  All library entities except `operator new` and `operator delete` are
696
  defined within the namespace `std` or namespaces nested within namespace
697
+ `std`.[^12]
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
713
+ `D`.
714
+
715
+ [*Example 1*: The reference to `is_array_v` in the specification of
716
+ `std::to_array` [[array.creation]] refers to
717
+ `::std::is_array_v`. — *end example*]
718
+
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]
 
739
  The headers listed in [[headers.cpp]], or, for a freestanding
740
  implementation, the subset of such headers that are provided by the
741
  implementation, are collectively known as the
742
  *importable C++ library headers*.
743
 
744
+ [*Note 1*: Importable C++ library headers can be imported
745
+ [[module.import]]. — *end note*]
746
 
747
  [*Example 1*:
748
 
749
  ``` cpp
750
  import <vector>; // imports the <vector> header unit
 
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
 
793
 
794
  [[c.annex.k.names]] lists the Annex K names that may be declared in some
795
  header. These names are also subject to the restrictions of 
796
  [[macro.names]].
797
 
798
+ #### Modules <a id="std.modules">[[std.modules]]</a>
799
+
800
+ The C++ standard library provides the following *C++ library modules*.
801
+
802
+ The named module `std` exports declarations in namespace `std` that are
803
+ provided by the importable C++ library headers ([[headers.cpp]] or the
804
+ 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.
826
+
827
+ A declaration in the standard library denotes the same entity regardless
828
+ of whether it was made reachable through including a header, importing a
829
+ header unit, or importing a C++ library module.
830
+
831
+ *Recommended practice:* Implementations should avoid exporting any other
832
+ declarations from the C++ library modules.
833
+
834
+ [*Note 2*: Like all named modules, the C++ library modules do not make
835
+ macros visible [[module.import]], such as `assert` [[cassert.syn]],
836
+ `errno` [[cerrno.syn]], `offsetof` [[cstddef.syn]], and `va_arg`
837
+ [[cstdarg.syn]]. — *end note*]
838
+
839
  #### Freestanding implementations <a id="compliance">[[compliance]]</a>
840
 
841
+ Two kinds of implementations are defined: hosted and freestanding
842
  [[intro.compliance]]; the kind of the implementation is
843
  *implementation-defined*. For a hosted implementation, this document
844
  describes the set of available headers.
845
 
846
  A freestanding implementation has an *implementation-defined* set of
 
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
 
 
926
  See also replacement functions [[replacement.functions]], runtime
927
  changes [[handler.functions]].
928
 
929
  ### Requirements on types and expressions <a id="utility.requirements">[[utility.requirements]]</a>
930
 
931
+ #### General <a id="utility.requirements.general">[[utility.requirements.general]]</a>
932
+
933
  [[utility.arg.requirements]] describes requirements on types and
934
  expressions used to instantiate templates defined in the C++ standard
935
  library. [[swappable.requirements]] describes the requirements on
936
  swappable types and swappable expressions.
937
  [[nullablepointer.requirements]] describes the requirements on
 
943
  #### Template argument requirements <a id="utility.arg.requirements">[[utility.arg.requirements]]</a>
944
 
945
  The template definitions in the C++ standard library refer to various
946
  named requirements whose details are set out in Tables 
947
  [[tab:cpp17.equalitycomparable]]– [[tab:cpp17.destructible]]. In these
948
+ tables,
949
+
950
+ - `T` denotes an object or reference type to be supplied by a C++
951
+ program instantiating a template,
952
+ - `a`, `b`, and `c` denote values of type (possibly const) `T`,
953
+ - `s` and `t` denote modifiable lvalues of type `T`,
954
+ - `u` denotes an identifier,
955
+ - `rv` denotes an rvalue of type `T`, and
956
+ - `v` denotes an lvalue of type (possibly const) `T` or an rvalue of
957
+ type `const T`.
958
 
959
  In general, a default constructor is not required. Certain container
960
  class member function signatures specify `T()` as a default argument.
961
  `T()` shall be a well-defined expression [[dcl.init]] if one of those
962
  signatures is called using the default argument [[dcl.fct.default]].
963
 
964
  **Table: Cpp17EqualityComparable requirements** <a id="cpp17.equalitycomparable">[cpp17.equalitycomparable]</a>
965
 
966
  | Expression | Return type |
967
  | ---------- | ----------- |
968
+ | `a == b` | `decltype(a == b)` models `boolean-testable` | `==` is an equivalence relation, that is, it has the following properties: For all `a`, `a == a`.; If `a == b`, then `b == a`.; If `a == b` and `b == c`, then `a == c`. |
969
 
970
 
971
  **Table: Cpp17LessThanComparable requirements** <a id="cpp17.lessthancomparable">[cpp17.lessthancomparable]</a>
972
 
973
  | Expression | Return type | Requirement |
974
+ | ---------- | ------------------------------------------- | ------------------------------------------------------ |
975
+ | `a < b` | `decltype(a < b)` models `boolean-testable` | `<` is a strict weak ordering relation [[alg.sorting]] |
976
 
977
 
978
  **Table: Cpp17DefaultConstructible requirements** <a id="cpp17.defaultconstructible">[cpp17.defaultconstructible]</a>
979
 
980
  | Expression | Post-condition |
 
982
  | `T t;` | object `t` is default-initialized |
983
  | `T u{};` | object `u` is value-initialized or aggregate-initialized |
984
  | `T()`<br>`T{}` | an object of type `T` is value-initialized or aggregate-initialized |
985
 
986
 
987
+ **Table: Cpp17MoveConstructible requirements** <a id="cpp17.moveconstructible">[cpp17.moveconstructible]</a>
988
+
989
+ | Expression | Post-condition |
990
+ | ----------- | ------------------------------------------------------------------ |
991
+ | `T u = rv;` | `u` is equivalent to the value of `rv` before the construction |
992
+ | `T(rv)` | `T(rv)` is equivalent to the value of `rv` before the construction |
993
+ | *[spans 2 columns]* `rv`'s state is unspecified *`rv` must still meet the requirements of the library component that is using it. The operations listed in those requirements must work as specified whether `rv` has been moved from or not.* |
994
+
995
 
996
  **Table: Cpp17CopyConstructible requirements (in addition to Cpp17MoveConstructible)** <a id="cpp17.copyconstructible">[cpp17.copyconstructible]</a>
997
 
998
  | Expression | Post-condition |
999
  | ---------- | --------------------------------------------------------- |
1000
  | `T u = v;` | the value of `v` is unchanged and is equivalent to ` u` |
1001
  | `T(v)` | the value of `v` is unchanged and is equivalent to `T(v)` |
1002
 
1003
 
1004
+ **Table: Cpp17MoveAssignable requirements** <a id="cpp17.moveassignable">[cpp17.moveassignable]</a>
1005
+
1006
+ | Expression | Return type | Return value | Post-condition |
1007
+ | ---------- | ----------- | ------------ | ------------------------------------------------------------------------------------------------------------- |
1008
+ | `t = rv` | `T&` | `t` | If `t` and `rv` do not refer to the same object, `t` is equivalent to the value of `rv` before the assignment |
1009
+ | *[spans 4 columns]* `rv`'s state is unspecified. *`rv` must still meet the requirements of the library component that is using it, whether or not `t` and `rv` refer to the same object. The operations listed in those requirements must work as specified whether `rv` has been moved from or not.* |
1010
+
1011
 
1012
  **Table: Cpp17CopyAssignable requirements (in addition to Cpp17MoveAssignable)** <a id="cpp17.copyassignable">[cpp17.copyassignable]</a>
1013
 
1014
  | Expression | Return type | Return value | Post-condition |
1015
  | ---------- | ----------- | ------------ | ------------------------------------------------------- |
1016
  | `t = v` | `T&` | `t` | `t` is equivalent to `v`, the value of `v` is unchanged |
1017
 
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
 
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:
1074
 
1075
  ``` cpp
1076
+ #include <cassert>
1077
  #include <utility>
1078
 
1079
+ // Preconditions: std::forward<T>(t) is swappable with std::forward<U>(u).
1080
  template<class T, class U>
1081
  void value_swap(T&& t, U&& u) {
1082
  using std::swap;
1083
+ swap(std::forward<T>(t), std::forward<U>(u)); // OK, uses ``swappable with'' conditions
1084
  // for rvalues and lvalues
1085
  }
1086
 
1087
+ // Preconditions: T meets the Cpp17Swappable requirements.
1088
  template<class T>
1089
  void lv_swap(T& t1, T& t2) {
1090
  using std::swap;
1091
+ swap(t1, t2); // OK, uses swappable conditions for lvalues of type T
1092
  }
1093
 
1094
  namespace N {
1095
  struct A { int m; };
1096
  struct Proxy { A* a; };
1097
  Proxy proxy(A& a) { return Proxy{ &a }; }
1098
 
1099
  void swap(A& x, Proxy p) {
1100
+ std::swap(x.m, p.a->m); // OK, uses context equivalent to swappable
1101
  // conditions for fundamental types
1102
  }
1103
  void swap(Proxy p, A& x) { swap(x, p); } // satisfy symmetry constraint
1104
  }
1105
 
 
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`.
 
1142
  No operation which is part of the *Cpp17NullablePointer* requirements
1143
  shall exit via an exception.
1144
 
1145
  In [[cpp17.nullablepointer]], `u` denotes an identifier, `t` denotes a
1146
  non-`const` lvalue of type `P`, `a` and `b` denote values of type
1147
+ (possibly const) `P`, and `np` denotes a value of type (possibly const)
1148
+ `std::nullptr_t`.
1149
 
1150
  **Table: Cpp17NullablePointer requirements** <a id="cpp17.nullablepointer">[cpp17.nullablepointer]</a>
1151
 
1152
  | Expression | Return type | Operational semantics |
1153
+ | -------------- | ------------------------------------------------------------------------- | --------------------------- |
1154
  | `P u(np);`<br> | | Ensures: `u == nullptr` |
1155
  | `P u = np;` | | |
1156
  | `P(np)` | | Ensures: `P(np) == nullptr` |
1157
  | `t = np` | `P&` | Ensures: `t == nullptr` |
1158
+ | `a != b` | `decltype(a != b)` models `boolean-testable` | `!(a == b)` |
1159
+ | `a == np` | `decltype(a == np)` and `decltype(np == a)` each model `boolean-testable` | `a == P()` |
1160
  | `np == a` | | |
1161
+ | `a != np` | `decltype(a != np)` and `decltype(np != a)` each model `boolean-testable` | `!(a == np)` |
1162
  | `np != a` | | |
1163
 
1164
 
1165
  #### *Cpp17Hash* requirements <a id="hash.requirements">[[hash.requirements]]</a>
1166
 
 
1171
  and *Cpp17Destructible* ([[cpp17.destructible]]) requirements, and
1172
  - the expressions shown in [[cpp17.hash]] are valid and have the
1173
  indicated semantics.
1174
 
1175
  Given `Key` is an argument type for function objects of type `H`, in
1176
+ [[cpp17.hash]] `h` is a value of type (possibly const) `H`, `u` is an
1177
  lvalue of type `Key`, and `k` is a value of a type convertible to
1178
+ (possibly const) `Key`.
1179
 
1180
  [*Note 1*: Thus all evaluations of the expression `h(k)` with the same
1181
  value for `k` yield the same result for a given execution of the
1182
  program. — *end note*]
1183
 
1184
  #### *Cpp17Allocator* requirements <a id="allocator.requirements">[[allocator.requirements]]</a>
1185
 
1186
+ ##### General <a id="allocator.requirements.general">[[allocator.requirements.general]]</a>
1187
+
1188
  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`,
1204
+ - `XX` denotes the type `allocator_traits<X>`,
1205
+ - `YY` denotes the type `allocator_traits<Y>`,
1206
+ - `a`, `a1`, `a2` denote lvalues of type `X`,
1207
+ - `u` denotes the name of a variable being declared,
1208
+ - `b` denotes a value of type `Y`,
1209
+ - `c` denotes a pointer of type `C*` through which indirection is valid,
1210
+ - `p` denotes a value of type `XX::pointer` obtained by calling
1211
+ `a1.allocate`, where `a1 == a`,
1212
+ - `q` denotes a value of type `XX::const_pointer` obtained by conversion
1213
+ from a value `p`,
1214
+ - `r` denotes a value of type `T&` obtained by the expression `*p`,
1215
+ - `w` denotes a value of type `XX::void_pointer` obtained by conversion
1216
+ from a value `p`,
1217
+ - `x` denotes a value of type `XX::const_void_pointer` obtained by
1218
+ conversion from a value `q` or a value `w`,
1219
+ - `y` denotes a value of type `XX::const_void_pointer` obtained by
1220
+ conversion from a result value of `YY::allocate`, or else a value of
1221
+ type (possibly const) `std::nullptr_t`,
1222
+ - `n` denotes a value of type `XX::size_type`,
1223
+ - `Args` denotes a template parameter pack, and
1224
+ - `args` denotes a function parameter pack with the pattern `Args&&`.
1225
+
1226
  The class template `allocator_traits` [[allocator.traits]] supplies a
1227
+ uniform interface to all allocator types. This subclause describes the
1228
+ requirements on allocator types and thus on types used to instantiate
1229
+ `allocator_traits`. A requirement is optional if a default for a given
1230
+ type or expression is specified. Within the standard library
1231
+ `allocator_traits` template, an optional requirement that is not
1232
+ supplied by an allocator is replaced by the specified default type or
1233
+ expression.
1234
+
1235
+ [*Note 1*: There are no program-defined specializations of
1236
+ `allocator_traits`. *end note*]
1237
+
1238
+ ``` cpp
1239
+ typename X::pointer
1240
+ ```
1241
+
1242
+ *Remarks:* Default: `T*`
1243
+
1244
+ ``` cpp
1245
+ typename X::const_pointer
1246
+ ```
1247
+
1248
+ *Mandates:* `XX::pointer` is convertible to `XX::const_pointer`.
1249
+
1250
+ *Remarks:* Default: `pointer_traits<XX::pointer>::rebind<const T>`
1251
+
1252
+ ``` cpp
1253
+ typename X::void_pointer
1254
+ typename Y::void_pointer
1255
+ ```
1256
+
1257
+ *Mandates:* `XX::pointer` is convertible to `XX::void_pointer`.
1258
+ `XX::void_pointer` and `YY::void_pointer` are the same type.
1259
+
1260
+ *Remarks:* Default: `pointer_traits<XX::pointer>::rebind<void>`
1261
+
1262
+ ``` cpp
1263
+ typename X::const_void_pointer
1264
+ typename Y::const_void_pointer
1265
+ ```
1266
+
1267
+ *Mandates:* `XX::pointer`, `XX::const_pointer`, and `XX::void_pointer`
1268
+ are convertible to `XX::const_void_pointer`. `XX::const_void_pointer`
1269
+ and `YY::const_void_pointer` are the same type.
1270
+
1271
+ *Remarks:* Default: `pointer_traits<XX::pointer>::rebind<const void>`
1272
+
1273
+ ``` cpp
1274
+ typename X::value_type
1275
+ ```
1276
+
1277
+ *Result:* Identical to `T`.
1278
+
1279
+ ``` cpp
1280
+ typename X::size_type
1281
+ ```
1282
+
1283
+ *Result:* An unsigned integer type that can represent the size of the
1284
+ largest object in the allocation model.
1285
+
1286
+ *Remarks:* Default: `make_unsigned_t<XX::difference_type>`
1287
+
1288
+ ``` cpp
1289
+ typename X::difference_type
1290
+ ```
1291
+
1292
+ *Result:* A signed integer type that can represent the difference
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`.
1304
+
1305
+ *Remarks:* If `Allocator` is a class template instantiation of the form
1306
  `SomeAllocator<T, Args>`, where `Args` is zero or more type arguments,
1307
  and `Allocator` does not supply a `rebind` member template, the standard
1308
  `allocator_traits` template uses `SomeAllocator<U, Args>` in place of
1309
+ `Allocator::rebind<U>::other` by default. For allocator types that are
1310
  not template instantiations of the above form, no default is provided.
1311
 
1312
+ [*Note 1*: The member class template `rebind` of `X` is effectively a
1313
+ typedef template. In general, if the name `Allocator` is bound to
1314
+ `SomeAllocator<T>`, then `Allocator::rebind<U>::other` is the same type
1315
+ as `SomeAllocator<U>`, where `SomeAllocator<T>::value_type` is `T` and
1316
+ `SomeAllocator<U>::value_type` is `U`. *end note*]
1317
+
1318
+ ``` cpp
1319
+ *p
1320
+ ```
1321
+
1322
+ *Result:* `T&`
1323
+
1324
+ ``` cpp
1325
+ *q
1326
+ ```
1327
+
1328
+ *Result:* `const T&`
1329
+
1330
+ *Ensures:* `*q` refers to the same object as `*p`.
1331
+
1332
+ ``` cpp
1333
+ p->m
1334
+ ```
1335
+
1336
+ *Result:* Type of `T::m`.
1337
+
1338
+ *Preconditions:* `(*p).m` is well-defined.
1339
+
1340
+ *Effects:* Equivalent to `(*p).m`.
1341
+
1342
+ ``` cpp
1343
+ q->m
1344
+ ```
1345
+
1346
+ *Result:* Type of `T::m`.
1347
+
1348
+ *Preconditions:* `(*q).m` is well-defined.
1349
+
1350
+ *Effects:* Equivalent to `(*q).m`.
1351
+
1352
+ ``` cpp
1353
+ static_cast<XX::pointer>(w)
1354
+ ```
1355
+
1356
+ *Result:* `XX::pointer`
1357
+
1358
+ *Ensures:* `static_cast<XX::pointer>(w) == p`.
1359
+
1360
+ ``` cpp
1361
+ static_cast<XX::const_pointer>(x)
1362
+ ```
1363
+
1364
+ *Result:* `XX::const_pointer`
1365
+
1366
+ *Ensures:* `static_cast<XX::const_pointer>(x) == q`.
1367
+
1368
+ ``` cpp
1369
+ pointer_traits<XX::pointer>::pointer_to(r)
1370
+ ```
1371
+
1372
+ *Result:* `XX::pointer`
1373
+
1374
+ *Ensures:* Same as `p`.
1375
+
1376
+ ``` cpp
1377
+ a.allocate(n)
1378
+ ```
1379
+
1380
+ *Result:* `XX::pointer`
1381
+
1382
+ *Effects:* Memory is allocated for an array of `n` `T` and such an
1383
+ object is created but array elements are not constructed.
1384
+
1385
+ [*Example 1*: When reusing storage denoted by some pointer value `p`,
1386
+ `launder(reinterpret_cast<T*>(new (p) byte[n * sizeof(T)]))` can be used
1387
+ to implicitly create a suitable array object and obtain a pointer to
1388
+ it. — *end example*]
1389
+
1390
+ *Throws:* `allocate` may throw an appropriate exception.
1391
+
1392
+ [*Note 2*: It is intended that `a.allocate` be an efficient means of
1393
+ allocating a single object of type `T`, even when `sizeof(T)` is small.
1394
+ That is, there is no need for a container to maintain its own free
1395
+ list. — *end note*]
1396
+
1397
+ *Remarks:* If `n == 0`, the return value is unspecified.
1398
+
1399
+ ``` cpp
1400
+ a.allocate(n, y)
1401
+ ```
1402
+
1403
+ *Result:* `XX::pointer`
1404
+
1405
+ *Effects:* Same as `a.allocate(n)`. The use of `y` is unspecified, but
1406
+ it is intended as an aid to locality.
1407
+
1408
+ *Remarks:* Default: `a.allocate(n)`
1409
+
1410
+ ``` cpp
1411
+ a.allocate_at_least(n)
1412
+ ```
1413
+
1414
+ *Result:* `allocation_result<XX::pointer, XX::size_type>`
1415
+
1416
+ *Returns:* `allocation_result<XX::pointer, XX::size_type>{ptr, count}`
1417
+ where `ptr` is memory allocated for an array of `count` `T` and such an
1418
+ object is created but array elements are not constructed, such that
1419
+ `count` ≥ `n`. If `n == 0`, the return value is unspecified.
1420
+
1421
+ *Throws:* `allocate_at_least` may throw an appropriate exception.
1422
+
1423
+ *Remarks:* Default: `{a.allocate(n), n}`.
1424
+
1425
+ ``` cpp
1426
+ a.deallocate(p, n)
1427
+ ```
1428
+
1429
+ *Result:* (not used)
1430
+
1431
+ *Preconditions:*
1432
+
1433
+ - If `p` is memory that was obtained by a call to `a.allocate_at_least`,
1434
+ let `ret` be the value returned and `req` be the value passed as the
1435
+ first argument of that call. `p` is equal to `ret.ptr` and `n` is a
1436
+ value such that `req` ≤ `n` ≤ `ret.count`.
1437
+ - Otherwise, `p` is a pointer value obtained from `allocate`. `n` equals
1438
+ the value passed as the first argument to the invocation of `allocate`
1439
+ which returned `p`.
1440
+
1441
+ `p` has not been invalidated by an intervening call to `deallocate`.
1442
+
1443
+ *Throws:* Nothing.
1444
+
1445
+ ``` cpp
1446
+ a.max_size()
1447
+ ```
1448
+
1449
+ *Result:* `XX::size_type`
1450
+
1451
+ *Returns:* The largest value `n` that can meaningfully be passed to
1452
+ `a.allocate(n)`.
1453
+
1454
+ *Remarks:* Default:
1455
+ `numeric_limits<size_type>::max() / sizeof(value_type)`
1456
+
1457
+ ``` cpp
1458
+ a1 == a2
1459
+ ```
1460
+
1461
+ *Result:* `bool`
1462
+
1463
+ *Returns:* `true` only if storage allocated from each can be deallocated
1464
+ via the other.
1465
+
1466
+ *Throws:* Nothing.
1467
+
1468
+ *Remarks:* `operator==` shall be reflexive, symmetric, and transitive.
1469
+
1470
+ ``` cpp
1471
+ a1 != a2
1472
+ ```
1473
+
1474
+ *Result:* `bool`
1475
+
1476
+ *Returns:* `!(a1 == a2)`.
1477
+
1478
+ ``` cpp
1479
+ a == b
1480
+ ```
1481
+
1482
+ *Result:* `bool`
1483
+
1484
+ *Returns:* `a == YY::rebind_alloc<T>(b)`.
1485
+
1486
+ ``` cpp
1487
+ a != b
1488
+ ```
1489
+
1490
+ *Result:* `bool`
1491
+
1492
+ *Returns:* `!(a == b)`.
1493
+
1494
+ ``` cpp
1495
+ X u(a);
1496
+ X u = a;
1497
+ ```
1498
+
1499
+ *Ensures:* `u == a`
1500
+
1501
+ *Throws:* Nothing.
1502
+
1503
+ ``` cpp
1504
+ X u(b);
1505
+ ```
1506
+
1507
+ *Ensures:* `Y(u) == b` and `u == X(b)`.
1508
+
1509
+ *Throws:* Nothing.
1510
+
1511
+ ``` cpp
1512
+ X u(std::move(a));
1513
+ X u = std::move(a);
1514
+ ```
1515
+
1516
+ *Ensures:* The value of `a` is unchanged and is equal to `u`.
1517
+
1518
+ *Throws:* Nothing.
1519
+
1520
+ ``` cpp
1521
+ X u(std::move(b));
1522
+ ```
1523
+
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`.
1535
+
1536
+ *Remarks:* Default: `construct_at(c, std::forward<Args>(args)...)`
1537
+
1538
+ ``` cpp
1539
+ a.destroy(c)
1540
+ ```
1541
+
1542
+ *Result:* (not used)
1543
+
1544
+ *Effects:* Destroys the object at `c`.
1545
+
1546
+ *Remarks:* Default: `destroy_at(c)`
1547
+
1548
+ ``` cpp
1549
+ a.select_on_container_copy_construction()
1550
+ ```
1551
+
1552
+ *Result:* `X`
1553
+
1554
+ *Returns:* Typically returns either `a` or `X()`.
1555
+
1556
+ *Remarks:* Default: `return a;`
1557
+
1558
+ ``` cpp
1559
+ typename X::propagate_on_container_copy_assignment
1560
+ ```
1561
+
1562
+ *Result:* Identical to or derived from `true_type` or `false_type`.
1563
+
1564
+ *Returns:* `true_type` only if an allocator of type `X` should be copied
1565
+ when the client container is copy-assigned; if so, `X` shall meet the
1566
+ *Cpp17CopyAssignable* requirements ([[cpp17.copyassignable]]) and the
1567
+ copy operation shall not throw exceptions.
1568
+
1569
+ *Remarks:* Default: `false_type`
1570
+
1571
+ ``` cpp
1572
+ typename X::propagate_on_container_move_assignment
1573
+ ```
1574
+
1575
+ *Result:* Identical to or derived from `true_type` or `false_type`.
1576
+
1577
+ *Returns:* `true_type` only if an allocator of type `X` should be moved
1578
+ when the client container is move-assigned; if so, `X` shall meet the
1579
+ *Cpp17MoveAssignable* requirements ([[cpp17.moveassignable]]) and the
1580
+ move operation shall not throw exceptions.
1581
+
1582
+ *Remarks:* Default: `false_type`
1583
+
1584
+ ``` cpp
1585
+ typename X::propagate_on_container_swap
1586
+ ```
1587
+
1588
+ *Result:* Identical to or derived from `true_type` or `false_type`.
1589
+
1590
+ *Returns:* `true_type` only if an allocator of type `X` should be
1591
+ swapped when the client container is swapped; if so, `X` shall meet the
1592
+ *Cpp17Swappable* requirements [[swappable.requirements]] and the `swap`
1593
+ operation shall not throw exceptions.
1594
+
1595
+ *Remarks:* Default: `false_type`
1596
+
1597
+ ``` cpp
1598
+ typename X::is_always_equal
1599
+ ```
1600
+
1601
+ *Result:* Identical to or derived from `true_type` or `false_type`.
1602
+
1603
+ *Returns:* `true_type` only if the expression `a1 == a2` is guaranteed
1604
+ to be `true` for any two (possibly const) values `a1`, `a2` of type `X`.
1605
+
1606
+ *Remarks:* Default: `is_empty<X>::type`
1607
 
1608
  An allocator type `X` shall meet the *Cpp17CopyConstructible*
1609
+ requirements ([[cpp17.copyconstructible]]). The `XX::pointer`,
1610
+ `XX::const_pointer`, `XX::void_pointer`, and `XX::const_void_pointer`
1611
+ types shall meet the *Cpp17NullablePointer* requirements (
1612
+ [[cpp17.nullablepointer]]). No constructor, comparison operator
1613
+ function, copy operation, move operation, or swap operation on these
1614
+ pointer types shall exit via an exception. `XX::pointer` and
1615
+ `XX::const_pointer` shall also meet the requirements for a
1616
+ *Cpp17RandomAccessIterator* [[random.access.iterators]] and the
1617
+ additional requirement that, when `p` and `(p + n)` are dereferenceable
1618
+ pointer values for some integral value `n`,
1619
 
1620
  ``` cpp
1621
+ addressof(*(p + n)) == addressof(*p) + n
1622
  ```
1623
 
1624
  is `true`.
1625
 
1626
  Let `x1` and `x2` denote objects of (possibly different) types
1627
+ `XX::void_pointer`, `XX::const_void_pointer`, `XX::pointer`, or
1628
+ `XX::const_pointer`. Then, `x1` and `x2` are *equivalently-valued*
1629
  pointer values, if and only if both `x1` and `x2` can be explicitly
1630
  converted to the two corresponding objects `px1` and `px2` of type
1631
+ `XX::const_pointer`, using a sequence of `static_cast`s using only these
1632
  four types, and the expression `px1 == px2` evaluates to `true`.
1633
 
1634
+ Let `w1` and `w2` denote objects of type `XX::void_pointer`. Then for
1635
+ the expressions
1636
 
1637
  ``` cpp
1638
  w1 == w2
1639
  w1 != w2
1640
  ```
1641
 
1642
  either or both objects may be replaced by an equivalently-valued object
1643
+ of type `XX::const_void_pointer` with no change in semantics.
1644
 
1645
+ Let `p1` and `p2` denote objects of type `XX::pointer`. Then for the
1646
  expressions
1647
 
1648
  ``` cpp
1649
  p1 == p2
1650
  p1 != p2
 
1654
  p1 > p2
1655
  p1 - p2
1656
  ```
1657
 
1658
  either or both objects may be replaced by an equivalently-valued object
1659
+ of type `XX::const_pointer` with no change in semantics.
1660
 
1661
  An allocator may constrain the types on which it can be instantiated and
1662
  the arguments for which its `construct` or `destroy` members may be
1663
  called. If a type cannot be used with a particular allocator, the
1664
  allocator class or the call to `construct` or `destroy` may fail to
 
1667
  If the alignment associated with a specific over-aligned type is not
1668
  supported by an allocator, instantiation of the allocator for that type
1669
  may fail. The allocator also may silently ignore the requested
1670
  alignment.
1671
 
1672
+ [*Note 2*: Additionally, the member function `allocate` for that type
1673
+ can fail by throwing an object of type `bad_alloc`. — *end note*]
1674
 
1675
  [*Example 1*:
1676
 
1677
  The following is an allocator class template supporting the minimal
1678
+ interface that meets the requirements of
1679
+ [[allocator.requirements.general]]:
1680
 
1681
  ``` cpp
1682
+ template<class T>
1683
  struct SimpleAllocator {
1684
+ using value_type = T;
1685
  SimpleAllocator(ctor args);
1686
 
1687
+ template<class U> SimpleAllocator(const SimpleAllocator<U>& other);
1688
 
1689
+ T* allocate(std::size_t n);
1690
+ void deallocate(T* p, std::size_t n);
1691
+
1692
+ template<class U> bool operator==(const SimpleAllocator<U>& rhs) const;
1693
  };
 
 
 
 
 
1694
  ```
1695
 
1696
  — *end example*]
1697
 
1698
  ##### Allocator completeness requirements <a id="allocator.requirements.completeness">[[allocator.requirements.completeness]]</a>
 
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.
1739
 
1740
+ [*Note 1*: The requirements on an explicit or partial specialization
1741
+ are stated by each variable template that grants such
1742
+ permission. — *end note*]
1743
+
1744
  The behavior of a C++ program is undefined if it declares
1745
 
1746
  - an explicit specialization of any member function of a standard
1747
  library class template, or
1748
  - an explicit specialization of any member function template of a
 
1761
  standard library function template. Unless `F` is designated an
1762
  *addressable function*, the behavior of a C++ program is unspecified
1763
  (possibly ill-formed) if it explicitly or implicitly attempts to form a
1764
  pointer to `F`.
1765
 
1766
+ [*Note 2*: Possible means of forming such pointers include application
1767
  of the unary `&` operator [[expr.unary.op]], `addressof`
1768
  [[specialized.addressof]], or a function-to-pointer standard conversion
1769
  [[conv.func]]. — *end note*]
1770
 
1771
  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
 
1794
  [*Example 1*: The top-level namespace `std2` is reserved for use by
1795
  future revisions of this International Standard. — *end example*]
1796
 
1797
  #### Reserved names <a id="reserved.names">[[reserved.names]]</a>
1798
 
1799
+ ##### General <a id="reserved.names.general">[[reserved.names.general]]</a>
1800
+
1801
  The C++ standard library reserves the following kinds of names:
1802
 
1803
  - macros
1804
  - global names
1805
  - names with external linkage
1806
 
1807
  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
 
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`,
 
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`,
 
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
 
 
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]
1897
+
1898
+ both in namespace `std` and in the global namespace.
1899
 
1900
  Each global function signature declared with external linkage in a
1901
  header is reserved to the implementation to designate that function
1902
+ signature with external linkage.[^23]
1903
 
1904
  Each name from the C standard library declared with external linkage is
1905
  reserved to the implementation for use as a name with `extern "C"`
1906
  linkage, both in namespace `std` and in the global namespace.
1907
 
1908
  Each function signature from the C standard library declared with
1909
  external linkage is reserved to the implementation for use as a function
1910
+ signature with both `extern "C"` and `extern "C++"` linkage,[^24]
1911
+
1912
+ or as a name of namespace scope in the global namespace.
1913
 
1914
  ##### Types <a id="extern.types">[[extern.types]]</a>
1915
 
1916
  For each type `T` from the C standard library, the types `::T` and
1917
  `std::T` are reserved to the implementation and, when defined, `::T`
1918
  shall be identical to `std::T`.
1919
 
1920
  ##### User-defined literal suffixes <a id="usrlit.suffix">[[usrlit.suffix]]</a>
1921
 
1922
  Literal suffix identifiers [[over.literal]] that do not start with an
1923
+ underscore are reserved for future standardization. Literal suffix
1924
+ identifiers that contain a double underscore `__` are reserved for use
1925
+ by C++ implementations.
1926
 
1927
  #### Headers <a id="alt.headers">[[alt.headers]]</a>
1928
 
1929
  If a file with a name equivalent to the derived file name for one of the
1930
  C++ standard library headers is not provided as part of the
 
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&)
 
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
 
 
2021
  on types used to instantiate standard library template components), the
2022
  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
2036
+ semantics of the applicable *Requirements* subclause
2037
+ [[allocator.requirements]], [[container.requirements]], [[iterator.requirements]], [[algorithms.requirements]], [[numeric.requirements]].
2038
+ Operations on such types can report a failure by throwing an exception
2039
+ unless otherwise specified.
 
2040
  - If any replacement function or handler function or destructor
2041
  operation exits via an exception, unless specifically allowed in the
2042
  applicable *Required behavior:* paragraph.
2043
+ - If an incomplete type [[term.incomplete.type]] is used as a template
2044
+ argument when instantiating a template component or evaluating a
2045
+ concept, unless specifically allowed for that component.
2046
 
2047
  #### Function arguments <a id="res.on.arguments">[[res.on.arguments]]</a>
2048
 
2049
  Each of the following applies to all arguments to functions defined in
2050
  the C++ standard library, unless explicitly stated otherwise.
 
2055
  - If a function argument is described as being an array, the pointer
2056
  actually passed to the function shall have a value such that all
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
2068
+ that lvalue to a library function (e.g., by calling the function with
2069
+ the argument `std::move(x)`), the program is effectively asking that
2070
+ function to treat that lvalue as a temporary object. The
2071
+ implementation is free to optimize away aliasing checks which would
2072
+ possibly be needed if the argument was an lvalue. — *end note*]
2073
 
2074
  #### Library object access <a id="res.on.objects">[[res.on.objects]]</a>
2075
 
2076
  The behavior of a program is undefined if calls to standard library
2077
  functions from different threads may introduce a data race. The
 
2089
  lifetime, the behavior is undefined unless otherwise specified.
2090
 
2091
  [*Note 2*: This applies even to objects such as mutexes intended for
2092
  thread synchronization. — *end note*]
2093
 
 
 
 
 
 
2094
  #### Semantic requirements <a id="res.on.requirements">[[res.on.requirements]]</a>
2095
 
2096
  A sequence `Args` of template arguments is said to *model* a concept `C`
2097
  if `Args` satisfies `C` [[temp.constr.decl]] and meets all semantic
2098
  requirements (if any) given in the specification of `C`.
 
2129
 
2130
  Certain types and macros are defined in more than one header. Every such
2131
  entity shall be defined such that any header that defines it may be
2132
  included after any other header that also defines it [[basic.def.odr]].
2133
 
2134
+ The C standard library headers [[support.c.headers]] shall include only
2135
  their corresponding C++ standard library header, as described in 
2136
  [[headers]].
2137
 
2138
  #### Restrictions on macro definitions <a id="res.on.macro.definitions">[[res.on.macro.definitions]]</a>
2139
 
 
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
 
2160
  Unless otherwise specified, calls made by functions in the standard
 
2189
  an implementation may declare a different set of member function
2190
  signatures, provided that any call to the member function that would
2191
  select an overload from the set of declarations described in this
2192
  document behaves as if that overload were selected.
2193
 
2194
+ [*Note 1*: For instance, an implementation can add parameters with
2195
  default values, or replace a member function with default arguments with
2196
  two or more member functions with equivalent behavior, or add additional
2197
  signatures for a member function name. — *end note*]
2198
 
2199
  #### Friend functions <a id="hidden.friends">[[hidden.friends]]</a>
 
2259
  current thread unless the objects are accessed directly or indirectly
2260
  via the function’s non-const arguments, including `this`.
2261
 
2262
  [*Note 1*: This means, for example, that implementations can’t use an
2263
  object with static storage duration for internal purposes without
2264
+ synchronization because doing so can cause a data race even in programs
2265
+ that do not explicitly share objects between threads. — *end note*]
2266
 
2267
  A C++ standard library function shall not access objects indirectly
2268
  accessible via its arguments or via elements of its container arguments
2269
  except by invoking functions required by its specification on those
2270
  container elements.
 
2308
  In any case:
2309
 
2310
  - Every base class described as `virtual` shall be virtual;
2311
  - Every base class not specified as `virtual` shall not be virtual;
2312
  - Unless explicitly stated otherwise, types with distinct names shall be
2313
+ distinct types. \[*Note 1*: There is an implicit exception to this
2314
+ rule for types that are described as synonyms
2315
+ [[dcl.typedef]], [[namespace.udecl]], such as `size_t`
2316
+ [[support.types]] and `streamoff` [[stream.types]]. — *end note*]
2317
 
2318
  All types specified in the C++ standard library shall be non-`final`
2319
  types unless otherwise specified.
2320
 
2321
  #### Restrictions on exception handling <a id="res.on.exception.handling">[[res.on.exception.handling]]</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
+
2342
  Implementations should report errors by throwing exceptions of or
2343
+ 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
 
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
 
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
 
2433
  [containers]: containers.md#containers
2434
  [contents]: #contents
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
2475
+ [freestanding.item]: #freestanding.item
2476
  [function.objects]: utilities.md#function.objects
2477
  [functions.within.classes]: #functions.within.classes
2478
  [global.functions]: #global.functions
2479
  [handler.functions]: #handler.functions
2480
  [hash.requirements]: #hash.requirements
 
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
 
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
2509
  [module.import]: module.md#module.import
2510
  [multibyte.strings]: #multibyte.strings
2511
  [namespace.constraints]: #namespace.constraints
2512
  [namespace.def]: dcl.md#namespace.def
2513
  [namespace.future]: #namespace.future
 
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
2544
  [res.on.macro.definitions]: #res.on.macro.definitions
2545
  [res.on.objects]: #res.on.objects
 
2546
  [res.on.requirements]: #res.on.requirements
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
 
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
2578
  [tab:cpp17.equalitycomparable]: #tab:cpp17.equalitycomparable
2579
  [temp]: temp.md#temp
2580
  [temp.concept]: temp.md#temp.concept
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
2592
+ [type.traits]: meta.md#type.traits
2593
  [using]: #using
2594
  [using.headers]: #using.headers
2595
  [using.linkage]: #using.linkage
2596
  [using.overview]: #using.overview
2597
  [usrlit.suffix]: #usrlit.suffix
2598
  [utilities]: utilities.md#utilities
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
 
2612
+ [^3]: Although in some cases the code given is unambiguously the optimum
2613
  implementation.
2614
 
2615
+ [^4]: To save space, items that do not apply to a class are omitted. For
2616
+ example, if a class does not specify any comparison operator
2617
+ functions, there will be no “Comparison operator functions”
2618
+ subclause.
2619
 
2620
+ [^5]: To save space, elements that do not apply to a function are
2621
  omitted. For example, if a function specifies no preconditions,
2622
  there will be no *Preconditions:* element.
2623
 
2624
+ [^6]: This simplifies the presentation of complexity requirements in
2625
  some cases.
2626
 
2627
+ [^7]: Examples from  [[utility.requirements]] include:
2628
  *Cpp17EqualityComparable*, *Cpp17LessThanComparable*,
2629
  *Cpp17CopyConstructible*. Examples from  [[iterator.requirements]]
2630
  include: *Cpp17InputIterator*, *Cpp17ForwardIterator*.
2631
 
2632
+ [^8]: Such as an integer type, with constant integer values
2633
  [[basic.fundamental]].
2634
 
 
 
2635
  [^9]: Many of the objects manipulated by function signatures declared in
2636
  `<cstring>` are character sequences or NTBSs. The size of some of
2637
  these character sequences is limited by a length value, maintained
2638
  separately from the character sequence.
2639
 
2640
  [^10]: A *string-literal*, such as `"abc"`, is a static NTBS.
2641
 
2642
+ [^11]: An NTBS that contains characters only from the basic literal
2643
  character set is also an NTMBS. Each multibyte character then
2644
  consists of a single byte.
2645
 
2646
+ [^12]: The C standard library headers [[support.c.headers]] also define
2647
  names within the global namespace, while the C++ headers for C
2648
+ library facilities [[headers]] can also define names within the
2649
  global namespace.
2650
 
2651
  [^13]: This gives implementers freedom to use inline namespaces to
2652
  support multiple configurations of the library.
2653
 
2654
  [^14]: A header is not necessarily a source file, nor are the sequences
2655
  delimited by `<` and `>` in header names necessarily valid source
2656
  file names [[cpp.include]].
2657
 
2658
  [^15]: It is intentional that there is no C++ header for any of these C
2659
+ headers: `<stdnoreturn.h>`, `<threads.h>`.
2660
 
2661
  [^16]: This disallows the practice, allowed in C, of providing a masking
2662
  macro in addition to the function prototype. The only way to achieve
2663
  equivalent inline behavior in C++ is to provide a definition as an
2664
  extern inline function.
 
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
 
2685
+ [^22]: The list of such reserved names includes `errno`, declared or
 
 
 
 
 
 
 
 
 
 
 
2686
  defined in `<cerrno>`.
2687
 
2688
+ [^23]: The list of such reserved function signatures with external
2689
  linkage includes `setjmp(jmp_buf)`, declared or defined in
2690
  `<csetjmp>`, and `va_end(va_list)`, declared or defined in
2691
  `<cstdarg>`.
2692
 
2693
+ [^24]: The function signatures declared in `<cuchar>`, `<cwchar>`, and
2694
  `<cwctype>` are always reserved, notwithstanding the restrictions
2695
  imposed in subclause 4.5.1 of Amendment 1 to the C Standard for
2696
  these headers.
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.
2709
 
2710
+ [^28]: In particular, they can report a failure to allocate storage by
2711
  throwing an exception of type `bad_alloc`, or a class derived from
2712
  `bad_alloc` [[bad.alloc]].