From Jason Turner

[library]

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

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpalf4bhi5/{from.md → to.md} +646 -525
tmp/tmpalf4bhi5/{from.md → to.md} RENAMED
@@ -28,11 +28,11 @@ framework for reporting errors in a C++program, including predefined
28
  exception classes.
29
 
30
  The general utilities library (Clause  [[utilities]]) includes
31
  components used by other library elements, such as a predefined storage
32
  allocator for dynamic storage management ([[basic.stc.dynamic]]), and
33
- components used as infrastructure in C++programs, such as a tuples,
34
  function wrappers, and time facilities.
35
 
36
  The strings library (Clause  [[strings]]) provides support for
37
  manipulating text represented as sequences of type `char`, sequences of
38
  type `char16_t`, sequences of type `char32_t`, sequences of type
@@ -73,194 +73,150 @@ communication.
73
 
74
  The C++standard library also makes available the facilities of the C
75
  standard library, suitably adjusted to ensure static type safety.
76
 
77
  The descriptions of many library functions rely on the C standard
78
- library for the signatures and semantics of those functions. In all such
79
- cases, any use of the `restrict` qualifier shall be omitted.
 
 
 
 
80
 
81
  ## Definitions <a id="definitions">[[definitions]]</a>
82
 
83
- #### 1 arbitrary-positional stream <a id="defns.arbitrary.stream">[[defns.arbitrary.stream]]</a>
 
84
 
85
  a stream (described in Clause  [[input.output]]) that can seek to any
86
  integral position within the length of the stream
87
- Every arbitrary-positional stream is also a repositional stream.
88
 
89
- #### 2 block <a id="defns.block">[[defns.block]]</a>
 
90
 
91
- place a thread in the blocked state
 
92
 
93
- #### 3 blocked thread <a id="defns.blocked">[[defns.blocked]]</a>
94
-
95
- a thread that is waiting for some condition (other than the availability
96
- of a processor) to be satisfied before it can continue execution[^1]
97
-
98
- #### 4 character <a id="defns.character">[[defns.character]]</a>
99
-
100
- \<Clauses  [[strings]], [[localization]], [[input.output]], and 
101
- [[re]]\> any object which, when treated sequentially, can represent
102
- text
103
- The term does not mean only `char`, `char16_t`, `char32_t`, and
104
- `wchar_t` objects, but any value that can be represented by a type that
105
- provides the definitions specified in these Clauses.
106
-
107
- #### 5 character container type <a id="defns.character.container">[[defns.character.container]]</a>
108
 
109
  a class or a type used to represent a *character*
110
- It is used for one of the template parameters of the string, iostream,
111
- and regular expression class templates. A character container type is a
112
- POD ([[basic.types]]) type.
113
 
114
- #### 6 comparison function <a id="defns.comparison">[[defns.comparison]]</a>
 
 
115
 
116
  an operator function ([[over.oper]]) for any of the equality (
117
  [[expr.eq]]) or relational ([[expr.rel]]) operators
118
 
119
- #### 7 component <a id="defns.component">[[defns.component]]</a>
120
-
121
  a group of library entities directly related as members, parameters, or
122
  return types
123
- For example, the class template `basic_string` and the non-member
124
- function templates that operate on strings are referred to as the
125
- *string component*.
126
 
127
- #### 8 deadlock <a id="defns.deadlock">[[defns.deadlock]]</a>
 
 
 
 
 
 
128
 
129
  one or more threads are unable to continue execution because each is
130
  blocked waiting for one or more of the others to satisfy some condition
131
 
132
- #### 9 default behavior <a id="defns.default.behavior.impl">[[defns.default.behavior.impl]]</a>
 
133
 
134
- \<implementation\> any specific behavior provided by the implementation,
135
- within the scope of the *required behavior*
136
 
137
- #### 10 default behavior <a id="defns.default.behavior.func">[[defns.default.behavior.func]]</a>
138
-
139
- \<specification\> a description of *replacement function* and *handler
140
- function* semantics
141
-
142
- #### 11 handler function <a id="defns.handler">[[defns.handler]]</a>
143
 
144
  a *non-reserved function* whose definition may be provided by a
145
  C++program
146
- A C++program may designate a handler function at various points in its
147
- execution by supplying a pointer to the function when calling any of the
148
- library functions that install handler functions (Clause 
149
- [[language.support]]).
150
 
151
- #### 12 iostream class templates <a id="defns.iostream.templates">[[defns.iostream.templates]]</a>
 
 
 
152
 
153
  templates, defined in Clause  [[input.output]], that take two template
154
  arguments
155
- The arguments are named `charT` and `traits`. The argument `charT` is a
156
- character container class, and the argument `traits` is a class which
157
- defines additional characteristics and functions of the character type
158
- represented by `charT` necessary to implement the iostream class
159
- templates.
160
 
161
- #### 13 modifier function <a id="defns.modifier">[[defns.modifier]]</a>
 
 
 
 
162
 
163
  a class member function ([[class.mfct]]) other than a constructor,
164
  assignment operator, or destructor that alters the state of an object of
165
  the class
166
 
167
- #### 14 move construction <a id="defns.move.constr">[[defns.move.constr]]</a>
168
-
169
- direct-initialization of an object of some type with an rvalue of the
170
- same type
171
-
172
- #### 15 move assignment <a id="defns.move.assign">[[defns.move.assign]]</a>
173
-
174
  assignment of an rvalue of some object type to a modifiable lvalue of
175
  the same type
176
 
177
- #### 16 object state <a id="defns.obj.state">[[defns.obj.state]]</a>
178
-
179
- the current value of all non-static class members of an object (
180
- [[class.mem]])
181
- The state of an object can be obtained by using one or more *observer
182
- functions*.
183
-
184
- #### 17 NTCTS <a id="defns.ntcts">[[defns.ntcts]]</a>
185
 
186
  a sequence of values that have *character type* that precede the
187
  terminating null character type value `charT()`
188
 
189
- #### 18 observer function <a id="defns.observer">[[defns.observer]]</a>
190
-
191
  a class member function ([[class.mfct]]) that accesses the state of an
192
  object of the class but does not alter that state
193
- Observer functions are specified as `const` member functions (
194
- [[class.this]]).
195
 
196
- #### 19 referenceable type <a id="defns.referenceable">[[defns.referenceable]]</a>
 
197
 
198
- An object type, a function type that does not have cv-qualifiers or a
199
- *ref-qualifier*, or a reference type. The term describes a type to which
200
- a reference can be created, including reference types.
201
 
202
- #### 20 replacement function <a id="defns.replacement">[[defns.replacement]]</a>
 
203
 
204
  a *non-reserved function* whose definition is provided by a C++program
205
- Only one definition for such a function is in effect for the duration of
206
- the program’s execution, as the result of creating the program (
207
- [[lex.phases]]) and resolving the definitions of all translation units (
208
- [[basic.link]]).
209
 
210
- #### 21 repositional stream <a id="defns.repositional.stream">[[defns.repositional.stream]]</a>
 
 
 
211
 
212
  a stream (described in Clause  [[input.output]]) that can seek to a
213
  position that was previously encountered
214
 
215
- #### 22 required behavior <a id="defns.required.behavior">[[defns.required.behavior]]</a>
216
-
217
  a description of *replacement function* and *handler function* semantics
218
  applicable to both the behavior provided by the implementation and the
219
  behavior of any such function definition in the program
220
- If such a function defined in a C++program fails to meet the required
221
- behavior when it executes, the behavior is undefined.
222
 
223
- #### 23 reserved function <a id="defns.reserved.function">[[defns.reserved.function]]</a>
 
 
224
 
225
  a function, specified as part of the C++standard library, that must be
226
  defined by the implementation
227
- If a C++program provides a definition for any reserved function, the
228
- results are undefined.
229
 
230
- #### 24 stable algorithm <a id="defns.stable">[[defns.stable]]</a>
 
231
 
232
  an algorithm that preserves, as appropriate to the particular algorithm,
233
  the order of elements
234
- Requirements for stable algorithms are given in  [[algorithm.stable]].
235
 
236
- #### 25 traits class <a id="defns.traits">[[defns.traits]]</a>
 
237
 
238
  a class that encapsulates a set of types and functions necessary for
239
  class templates and function templates to manipulate objects of types
240
  for which they are instantiated
241
- Traits classes defined in Clauses  [[strings]], [[localization]] and 
242
- [[input.output]] are *character traits*, which provide the character
243
- handling support needed by the string and iostream classes.
244
 
245
- #### 26 unblock <a id="defns.unblock">[[defns.unblock]]</a>
246
-
247
- place a thread in the unblocked state
248
-
249
- #### 27 valid but unspecified state <a id="defns.valid">[[defns.valid]]</a>
250
-
251
- an object state that is not specified except that the object’s
252
  invariants are met and operations on the object behave as specified for
253
  its type
254
- If an object `x` of type `std::vector<int>` is in a valid but
255
- unspecified state, `x.empty()` can be called unconditionally, and
256
- `x.front()` can be called only if `x.empty()` returns `false`.
257
 
258
- ## Additional definitions <a id="defns.additional">[[defns.additional]]</a>
259
-
260
- [[intro.defs]] defines additional terms used elsewhere in this
261
- International Standard.
262
 
263
  ## Method of description (Informative) <a id="description">[[description]]</a>
264
 
265
  This subclause describes the conventions used to specify the C++standard
266
  library. [[structure]] describes the structure of the normative Clauses 
@@ -269,16 +225,16 @@ library. [[structure]] describes the structure of the normative Clauses 
269
 
270
  ### Structure of each clause <a id="structure">[[structure]]</a>
271
 
272
  #### Elements <a id="structure.elements">[[structure.elements]]</a>
273
 
274
- Each library clause contains the following elements, as applicable:[^2]
275
 
276
  - Summary
277
  - Requirements
278
  - Detailed specifications
279
- - References to the Standard C library
280
 
281
  #### Summary <a id="structure.summary">[[structure.summary]]</a>
282
 
283
  The Summary provides a synopsis of the category, and introduces the
284
  first-level subclauses. Each subclause also provides a summary, listing
@@ -312,12 +268,12 @@ The string and iostream components use an explicit representation of
312
  operations required of template arguments. They use a class template
313
  `char_traits` to define these constraints.
314
 
315
  Interface convention requirements are stated as generally as possible.
316
  Instead of stating “class X has to define a member function
317
- `operator++()`,” the interface requires “for any object `x` of class
318
- `X`, `++x` is defined.” That is, whether the operator is a member is
319
  unspecified.
320
 
321
  Requirements are stated in terms of well-defined expressions that define
322
  valid terms of the types that satisfy the requirements. For every set of
323
  well-defined expression requirements there is a table that specifies an
@@ -330,34 +286,34 @@ Template argument requirements are sometimes referenced by name. See 
330
  [[type.descriptions]].
331
 
332
  In some cases the semantic requirements are presented as C++code. Such
333
  code is intended as a specification of equivalence of a construct to
334
  another construct, not necessarily as the way the construct must be
335
- implemented.[^3]
336
 
337
  #### Detailed specifications <a id="structure.specifications">[[structure.specifications]]</a>
338
 
339
  The detailed specifications each contain the following elements:
340
 
341
  - name and brief description
342
- - synopsis (class definition or function prototype, as appropriate)
343
  - restrictions on template arguments, if any
344
  - description of class invariants
345
  - description of function semantics
346
 
347
  Descriptions of class member functions follow the order (as
348
- appropriate):[^4]
349
 
350
  - constructor(s) and destructor
351
  - copying, moving & assignment functions
352
  - comparison functions
353
  - modifier functions
354
  - observer functions
355
  - operators and other non-member functions
356
 
357
  Descriptions of function semantics contain the following elements (as
358
- appropriate):[^5]
359
 
360
  - *Requires:* the preconditions for calling the function
361
  - *Effects:* the actions performed by the function
362
  - *Synchronization:* the synchronization operations (
363
  [[intro.multithread]]) applicable to the function
@@ -366,24 +322,23 @@ appropriate):[^5]
366
  - *Throws:* any exceptions thrown by the function, and the conditions
367
  that would cause the exception
368
  - *Complexity:* the time and/or space complexity of the function
369
  - *Remarks:* additional semantic constraints on the function
370
  - *Error conditions:* the error conditions for error codes reported by
371
- the function.
372
- - *Notes:* non-normative comments about the function
373
 
374
  Whenever the *Effects:* element specifies that the semantics of some
375
  function `F` are *Equivalent to* some code sequence, then the various
376
  elements are interpreted as follows. If `F`’s semantics specifies a
377
  *Requires:* element, then that requirement is logically imposed prior to
378
  the *equivalent-to* semantics. Next, the semantics of the code sequence
379
- are determined by the *Requires:* , *Effects:* , *Postconditions:* ,
380
- *Returns:* , *Throws:* , *Complexity:* , *Remarks:* , *Error
381
- conditions:* , and *Notes:* specified for the function invocations
382
  contained in the code sequence. The value returned from `F` is specified
383
  by `F`’s *Returns:* element, or if `F` has no *Returns:* element, a
384
- non-`void` return from `F` is specified by the *Returns:* elements in
385
  the code sequence. If `F`’s semantics contains a *Throws:* ,
386
  *Postconditions:* , or *Complexity:* element, then that supersedes any
387
  occurrences of that element in the code sequence.
388
 
389
  For non-reserved replacement and handler functions, Clause 
@@ -394,11 +349,11 @@ describes a function definition provided by the implementation. The
394
  provided by either the implementation or a C++program. Where no
395
  distinction is explicitly made in the description, the behavior
396
  described is the required behavior.
397
 
398
  If the formulation of a complexity requirement calls for a negative
399
- number of operations, the actual requirement is zero operations.[^6]
400
 
401
  Complexity requirements specified in the library clauses are upper
402
  bounds, and implementations that provide better complexity guarantees
403
  satisfy the requirements.
404
 
@@ -407,12 +362,11 @@ conditions are listed, together with a suitable explanation, as the
407
  `enum class errc` constants ([[syserr]]).
408
 
409
  #### C library <a id="structure.see.also">[[structure.see.also]]</a>
410
 
411
  Paragraphs labeled “” contain cross-references to the relevant portions
412
- of this International Standard and the ISO C standard, which is
413
- incorporated into this International Standard by reference.
414
 
415
  ### Other conventions <a id="conventions">[[conventions]]</a>
416
 
417
  This subclause describes several editorial conventions used to describe
418
  the contents of the C++standard library. These conventions are for
@@ -422,37 +376,58 @@ member functions ([[functions.within.classes]]).
422
  #### Type descriptions <a id="type.descriptions">[[type.descriptions]]</a>
423
 
424
  ##### General <a id="type.descriptions.general">[[type.descriptions.general]]</a>
425
 
426
  The Requirements subclauses may describe names that are used to specify
427
- constraints on template arguments.[^7] These names are used in library
428
  Clauses to describe the types that may be supplied as arguments by a
429
  C++program when instantiating template components from the library.
430
 
431
  Certain types defined in Clause  [[input.output]] are used to describe
432
  implementation-defined types. They are based on other types, but with
433
  added constraints.
434
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
435
  ##### Enumerated types <a id="enumerated.types">[[enumerated.types]]</a>
436
 
437
  Several types defined in Clause  [[input.output]] are *enumerated
438
  types*. Each enumerated type may be implemented as an enumeration or as
439
- a synonym for an enumeration.[^8]
440
 
441
- The enumerated type *enumerated* can be written:
442
 
443
  ``` cpp
444
- enum enumerated { V0, V1, V2, V3, ..... };
445
 
446
- static const enumerated C0 (V0);
447
- static const enumerated C1 (V1);
448
- static const enumerated C2 (V2);
449
- static const enumerated C3 (V3);
450
  .....
451
  ```
452
 
453
- Here, the names *C0*, *C1*, etc. represent *enumerated elements* for
454
  this particular enumerated type. All such elements have distinct values.
455
 
456
  ##### Bitmask types <a id="bitmask.types">[[bitmask.types]]</a>
457
 
458
  Several types defined in Clauses  [[language.support]] through 
@@ -462,20 +437,19 @@ operators, as an integer type, or as a `bitset` ([[template.bitset]]).
462
 
463
  The bitmask type *bitmask* can be written:
464
 
465
  ``` cpp
466
  // For exposition only.
467
- // int_type is an integral type capable of
468
- // representing all values of the bitmask type.
469
  enum bitmask : int_type {
470
- V0 = 1 << 0, V1 = 1 << 1, V2 = 1 << 2, V3 = 1 << 3, .....
471
  };
472
 
473
- constexpr bitmask C0(V0{});
474
- constexpr bitmask C1(V1{});
475
- constexpr bitmask C2(V2{});
476
- constexpr bitmask C3(V3{});
477
  .....
478
 
479
  constexpr bitmask{} operator&(bitmask{} X, bitmask{} Y) {
480
  return static_cast<bitmask{}>(
481
  static_cast<int_type>(X) & static_cast<int_type>(Y));
@@ -500,14 +474,14 @@ bitmask{}& operator|=(bitmask{}& X, bitmask{} Y) {
500
  bitmask{}& operator^=(bitmask{}& X, bitmask{} Y) {
501
  X = X ^ Y; return X;
502
  }
503
  ```
504
 
505
- Here, the names *C0*, *C1*, etc. represent *bitmask elements* for this
506
  particular bitmask type. All such elements have distinct, nonzero values
507
- such that, for any pair *Ci* and *Cj* where *i* != *j*, *Ci* & *Ci* is
508
- nonzero and *Ci* & *Cj* is zero. Additionally, the value 0 is used to
509
  represent an *empty bitmask*, in which no bitmask elements are set.
510
 
511
  The following terms apply to objects and values of bitmask types:
512
 
513
  - To *set* a value *Y* in an object *X* is to evaluate the expression
@@ -521,87 +495,91 @@ The following terms apply to objects and values of bitmask types:
521
 
522
  The C standard library makes widespread use of characters and character
523
  sequences that follow a few uniform conventions:
524
 
525
  - A *letter* is any of the 26 lowercase or 26 uppercase letters in the
526
- basic execution character set.[^9]
527
  - The *decimal-point character* is the (single-byte) character used by
528
  functions that convert between a (single-byte) character sequence and
529
  a value of one of the floating-point types. It is used in the
530
  character sequence to denote the beginning of a fractional part. It is
531
  represented in Clauses  [[language.support]] through  [[thread]] and
532
  Annex  [[depr]] by a period, `'.'`, which is also its value in the
533
  `"C"` locale, but may change during program execution by a call to
534
- `setlocale(int, const char*)`,[^10] or by a change to a `locale`
535
  object, as described in Clauses  [[locales]] and  [[input.output]].
536
- - A *character sequence* is an array object ([[dcl.array]]) *A* that
537
- can be declared as `T A[N]`, where *T* is any of the types `char`,
538
  `unsigned char`, or `signed char` ([[basic.fundamental]]), optionally
539
  qualified by any combination of `const` or `volatile`. The initial
540
  elements of the array have defined contents up to and including an
541
  element determined by some predicate. A character sequence can be
542
- designated by a pointer value *S* that points to its first element.
543
 
544
  ###### Byte strings <a id="byte.strings">[[byte.strings]]</a>
545
 
546
  A *null-terminated byte string*, or NTBS, is a character sequence whose
547
  highest-addressed element with defined content has the value zero (the
548
  *terminating null* character); no other element in the sequence has the
549
- value zero. [^11]
550
 
551
  The *length* of an NTBS is the number of elements that precede the
552
  terminating null character. An *empty* NTBS has a length of zero.
553
 
554
  The *value* of an NTBS is the sequence of values of the elements up to
555
  and including the terminating null character.
556
 
557
- A *static* NTBS is an NTBSwith static storage duration.[^12]
558
 
559
  ###### Multibyte strings <a id="multibyte.strings">[[multibyte.strings]]</a>
560
 
561
- A *null-terminated multibyte string,* or NTMBS, is an NTBSthat
562
  constitutes a sequence of valid multibyte characters, beginning and
563
- ending in the initial shift state.[^13]
564
 
565
  A *static* NTMBS is an NTMBSwith static storage duration.
566
 
567
  #### Functions within classes <a id="functions.within.classes">[[functions.within.classes]]</a>
568
 
569
  For the sake of exposition, Clauses  [[language.support]] through 
570
  [[thread]] and Annex  [[depr]] do not describe copy/move constructors,
571
  assignment operators, or (non-virtual) destructors with the same
572
  apparent semantics as those that can be generated by default (
573
- [[class.ctor]], [[class.dtor]], [[class.copy]]).
 
 
 
574
 
575
- It is unspecified whether the implementation provides explicit
576
- definitions for such member function signatures, or for virtual
577
- destructors that can be generated by default.
 
 
 
 
578
 
579
  #### Private members <a id="objects.within.classes">[[objects.within.classes]]</a>
580
 
581
  Clauses  [[language.support]] through  [[thread]] and Annex  [[depr]] do
582
  not specify the representation of classes, and intentionally omit
583
  specification of class members ([[class.mem]]). An implementation may
584
  define static or non-static class members, or both, as needed to
585
  implement the semantics of the member functions specified in Clauses 
586
  [[language.support]] through  [[thread]] and Annex  [[depr]].
587
 
588
- Objects of certain classes are sometimes required by the external
589
- specifications of their classes to store data, apparently in member
590
- objects. For the sake of exposition, some subclauses provide
591
- representative declarations, and semantic requirements, for private
592
- member objects of classes that meet the external specifications of the
593
- classes. The declarations for such member objects and the definitions of
594
- related member types are followed by a comment that ends with
595
- *exposition only*, as in:
596
 
597
  ``` cpp
598
  streambuf* sb; // exposition only
599
  ```
600
 
601
  An implementation may use any technique that provides equivalent
602
- external behavior.
603
 
604
  ## Library-wide requirements <a id="requirements">[[requirements]]</a>
605
 
606
  This subclause specifies requirements that apply to the entire
607
  C++standard library. Clauses  [[language.support]] through  [[thread]]
@@ -618,59 +596,65 @@ constraints on types and functions used with the C++standard library,
618
  [[constraints]] describes constraints on well-formed C++programs, and
619
  [[conforming]] describes constraints on conforming implementations.
620
 
621
  ### Library contents and organization <a id="organization">[[organization]]</a>
622
 
623
- [[contents]] describes the entities defined in the C++standard library.
624
- [[headers]] lists the standard library headers and some constraints on
625
- those headers. [[compliance]] lists requirements for a freestanding
626
- implementation of the C++ standard library.
627
 
628
  #### Library contents <a id="contents">[[contents]]</a>
629
 
630
- The C++standard library provides definitions for the following types of
631
- entities: macros, values, types, templates, classes, functions, objects.
 
632
 
633
- All library entities except macros, `operator new` and `operator delete`
634
- are defined within the namespace `std` or namespaces nested within
635
- namespace `std`.[^14] It is unspecified whether names declared in a
636
- specific namespace are declared directly in that namespace or in an
637
- inline namespace inside that namespace.[^15]
638
 
639
  Whenever a name `x` defined in the standard library is mentioned, the
640
  name `x` is assumed to be fully qualified as `::std::x`, unless
641
- explicitly described otherwise. For example, if the Effects section for
642
- library function `F` is described as calling library function `G`, the
643
- function `::std::G` is meant.
644
 
645
  #### Headers <a id="headers">[[headers]]</a>
646
 
647
  Each element of the C++standard library is declared or defined (as
648
- appropriate) in a *header*.[^16]
649
 
650
- The C++standard library provides 53 *C++library headers*, as shown in
651
  Table  [[tab:cpp.library.headers]].
652
 
653
  **Table: C++library headers** <a id="tab:cpp.library.headers">[tab:cpp.library.headers]</a>
654
 
655
- | | | | | |
656
- | ---------------------- | -------------------- | ----------- | -------------------- | ----------------- |
657
- | `<algorithm>` | `<fstream>` | `<list>` | `<regex>` | `<tuple>` |
658
- | `<array>` | `<functional>` | `<locale>` | `<scoped_allocator>` | `<type_traits>` |
659
- | `<atomic>` | `<future>` | `<map>` | `<set>` | `<typeindex>` |
660
- | `<bitset>` | `<initializer_list>` | `<memory>` | `<sstream>` | `<typeinfo>` |
661
- | `<chrono>` | `<iomanip>` | `<mutex>` | `<stack>` | `<unordered_map>` |
662
- | `<codecvt>` | `<ios>` | `<new>` | `<stdexcept>` | `<unordered_set>` |
663
- | `<complex>` | `<iosfwd>` | `<numeric>` | `<streambuf>` | `<utility>` |
664
- | `<condition_variable>` | `<iostream>` | `<ostream>` | `<string>` | `<valarray>` |
665
- | `<deque>` | `<istream>` | `<queue>` | `<strstream>` | `<vector>` |
666
- | `<exception>` | `<iterator>` | `<random>` | `<system_error>` | |
667
- | `<forward_list>` | `<limits>` | `<ratio>` | `<thread>` | |
 
 
 
 
 
668
 
669
 
670
- The facilities of the C standard Library are provided in 26 additional
671
- headers, as shown in Table  [[tab:cpp.c.headers]].
672
 
673
  **Table: C++headers for C library facilities** <a id="tab:cpp.c.headers">[tab:cpp.c.headers]</a>
674
 
675
  | | | | | |
676
  | ------------ | ------------- | ------------- | ----------- | ----------- |
@@ -680,34 +664,77 @@ headers, as shown in Table  [[tab:cpp.c.headers]].
680
  | `<cerrno>` | `<clocale>` | `<cstdbool>` | `<ctgmath>` | |
681
  | `<cfenv>` | `<cmath>` | `<cstddef>` | `<ctime>` | |
682
  | `<cfloat>` | `<csetjmp>` | `<cstdint>` | `<cuchar>` | |
683
 
684
 
685
- Except as noted in Clauses  [[language.support]] through  [[thread]] and
686
- Annex  [[depr]], the contents of each header `cname` shall be the same
687
- as that of the corresponding header `name.h`, as specified in the C
688
- standard library ([[intro.refs]]) or the C Unicode TR, as appropriate,
689
- as if by inclusion. In the C++standard library, however, the
690
  declarations (except for names which are defined as macros in C) are
691
  within namespace scope ([[basic.scope.namespace]]) of the namespace
692
- `std.` It is unspecified whether these names are first declared within
693
- the global namespace scope and are then injected into namespace `std` by
694
- explicit *using-declaration*s ([[namespace.udecl]]).
 
 
695
 
696
  Names which are defined as macros in C shall be defined as macros in the
697
  C++ standard library, even if C grants license for implementation as
698
- functions. The names defined as macros in C include the following:
699
- `assert`, `offsetof`, `setjmp`, `va_arg`, `va_end`, and `va_start`.
 
 
 
700
 
701
  Names that are defined as functions in C shall be defined as functions
702
- in the C++standard library.[^17]
703
 
704
  Identifiers that are keywords or operators in C++shall not be defined as
705
- macros in C++standard library headers.[^18]
706
 
707
  [[depr.c.headers]], C standard library headers, describes the effects of
708
- using the `name.h` (C header) form in a C++program.[^19]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
709
 
710
  #### Freestanding implementations <a id="compliance">[[compliance]]</a>
711
 
712
  Two kinds of implementations are defined: *hosted* and *freestanding* (
713
  [[intro.compliance]]). For a hosted implementation, this International
@@ -718,23 +745,24 @@ headers. This set shall include at least the headers shown in Table 
718
  [[tab:cpp.headers.freestanding]].
719
 
720
  **Table: C++headers for freestanding implementations** <a id="tab:cpp.headers.freestanding">[tab:cpp.headers.freestanding]</a>
721
 
722
  | Subclause | | Header |
723
- | ---------------------- | ------------------------- | -------------------------------------- |
724
  | | | `<ciso646>` |
725
  | [[support.types]] | Types | `<cstddef>` |
726
  | [[support.limits]] | Implementation properties | `<cfloat>` `<limits>` `<climits>` |
727
  | [[cstdint]] | Integer types | `<cstdint>` |
728
  | [[support.start.term]] | Start and termination | `<cstdlib>` |
729
  | [[support.dynamic]] | Dynamic memory management | `<new>` |
730
  | [[support.rtti]] | Type identification | `<typeinfo>` |
731
  | [[support.exception]] | Exception handling | `<exception>` |
732
  | [[support.initlist]] | Initializer lists | `<initializer_list>` |
733
- | [[support.runtime]] | Other runtime support | `<cstdalign>` `<cstdarg>` `<cstdbool>` |
734
  | [[meta]] | Type traits | `<type_traits>` |
735
  | [[atomics]] | Atomics | `<atomic>` |
 
736
 
737
 
738
  The supplied version of the header `<cstdlib>` shall declare at least
739
  the functions `abort`, `atexit`, `at_quick_exit`, `exit`, and
740
  `quick_exit` ([[support.start.term]]). The other headers listed in this
@@ -757,13 +785,13 @@ appropriate `#include` preprocessing directive ([[cpp.include]]).
757
 
758
  A translation unit may include library headers in any order (Clause 
759
  [[lex]]). Each may be included more than once, with no effect different
760
  from being included exactly once, except that the effect of including
761
  either `<cassert>` or `<assert.h>` depends each time on the lexically
762
- current definition of `NDEBUG`.[^20]
763
 
764
- A translation unit shall include a header only outside of any external
765
  declaration or definition, and shall include the header lexically before
766
  the first reference in that translation unit to any of the entities
767
  declared in that header. No diagnostic is required.
768
 
769
  #### Linkage <a id="using.linkage">[[using.linkage]]</a>
@@ -773,17 +801,17 @@ Entities in the C++standard library have external linkage (
773
  the default `extern "C++"` linkage ([[dcl.link]]).
774
 
775
  Whether a name from the C standard library declared with external
776
  linkage has `extern "C"` or `extern "C++"` linkage is
777
  *implementation-defined*. It is recommended that an implementation use
778
- `extern "C++"` linkage for this purpose.[^21]
779
 
780
  Objects and functions defined in the library and required by a
781
  C++program are included in the program prior to program startup.
782
 
783
- replacement functions ([[replacement.functions]]), run-time changes (
784
- [[handler.functions]]).
785
 
786
  ### Requirements on types and expressions <a id="utility.requirements">[[utility.requirements]]</a>
787
 
788
  [[utility.arg.requirements]] describes requirements on types and
789
  expressions used to instantiate templates defined in the C++standard
@@ -796,77 +824,71 @@ describes the requirements on hash function objects.
796
  allocators.
797
 
798
  #### Template argument requirements <a id="utility.arg.requirements">[[utility.arg.requirements]]</a>
799
 
800
  The template definitions in the C++standard library refer to various
801
- named requirements whose details are set out in tables 
802
- [[equalitycomparable]]– [[destructible]]. In these tables, `T` is an
803
- object or reference type to be supplied by a C++program instantiating a
804
- template; `a`, `b`, and `c` are values of type (possibly `const`) `T`;
805
- `s` and `t` are modifiable lvalues of type `T`; `u` denotes an
806
- identifier; `rv` is an rvalue of type `T`; and `v` is an lvalue of type
807
- (possibly `const`) `T` or an rvalue of type `const T`.
808
 
809
  In general, a default constructor is not required. Certain container
810
  class member function signatures specify `T()` as a default argument.
811
  `T()` shall be a well-defined expression ([[dcl.init]]) if one of those
812
  signatures is called using the default argument ([[dcl.fct.default]]).
813
 
814
  **Table: `EqualityComparable` requirements** <a id="equalitycomparable">[equalitycomparable]</a>
815
 
816
- | | | |
817
- | -------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
818
  | `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`. |
819
 
820
  **Table: `LessThanComparable` requirements** <a id="lessthancomparable">[lessthancomparable]</a>
821
 
822
- | | | |
823
- | ------- | --------------------- | --------------------------------------------------------- |
824
  | `a < b` | convertible to `bool` | `<` is a strict weak ordering relation~([[alg.sorting]]) |
825
 
826
  **Table: `DefaultConstructible` requirements** <a id="defaultconstructible">[defaultconstructible]</a>
827
 
828
- | | |
829
- | -------- | --------------------------------------------------- |
830
  | `T t;` | object `t` is default-initialized |
831
- | `T u{};` | object `u` is value-initialized |
832
- | `T()` | a temporary object of type `T` is value-initialized |
833
- | `T{}` | |
834
 
835
- **Table: `MoveConstructible` requirements** <a id="moveconstructible">[moveconstructible]</a>
836
-
837
- | | |
838
- | ----------- | ------------------------------------------------------------------ |
839
- | `T u = rv;` | `u` is equivalent to the value of `rv` before the construction |
840
- | `T(rv)` | `T(rv)` is equivalent to the value of `rv` before the construction |
841
- | *[spans 2 columns]* `rv`'s state is unspecified \enternote `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. \exitnote |
842
 
843
  **Table: `CopyConstructible` requirements (in addition to `MoveConstructible`)** <a id="copyconstructible">[copyconstructible]</a>
844
 
845
- | | |
846
  | ---------- | --------------------------------------------------------- |
847
  | `T u = v;` | the value of `v` is unchanged and is equivalent to ` u` |
848
  | `T(v)` | the value of `v` is unchanged and is equivalent to `T(v)` |
849
 
850
- **Table: `MoveAssignable` requirements** <a id="moveassignable">[moveassignable]</a>
851
-
852
- | | | | |
853
- | -------- | ---- | --- | ------------------------------------------------------------ |
854
- | `t = rv` | `T&` | `t` | `t` is equivalent to the value of `rv` before the assignment |
855
- | *[spans 4 columns]* `rv`'s state is unspecified. \enternote\ `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. \exitnote |
856
 
857
  **Table: `CopyAssignable` requirements (in addition to `MoveAssignable`)** <a id="copyassignable">[copyassignable]</a>
858
 
859
- | | | | |
860
- | ------- | ---- | --- | ------------------------------------------------------- |
861
  | `t = v` | `T&` | `t` | `t` is equivalent to `v`, the value of `v` is unchanged |
862
 
863
 
864
  **Table: `Destructible` requirements** <a id="destructible">[destructible]</a>
865
 
866
- | | |
867
- | -------- | --------------------------------------------------------------------- |
868
  | `u.~T()` | All resources owned by `u` are reclaimed, no exception is propagated. |
869
 
870
 
871
  #### `Swappable` requirements <a id="swappable.requirements">[[swappable.requirements]]</a>
872
 
@@ -890,28 +912,30 @@ overload resolution ([[over.match]]) on a candidate set that includes:
890
  - the two `swap` function templates defined in `<utility>` (
891
  [[utility]]) and
892
  - the lookup set produced by argument-dependent lookup (
893
  [[basic.lookup.argdep]]).
894
 
895
- If `T` and `U` are both fundamental types or arrays of fundamental types
896
- and the declarations from the header `<utility>` are in scope, the
897
- overall lookup set described above is equivalent to that of the
898
- qualified name lookup applied to the expression `std::swap(t, u)` or
899
- `std::swap(u, t)` as appropriate.
900
 
901
- It is unspecified whether a library component that has a swappable
902
- requirement includes the header `<utility>` to ensure an appropriate
903
- evaluation context.
904
 
905
  An rvalue or lvalue `t` is *swappable* if and only if `t` is swappable
906
  with any rvalue or lvalue, respectively, of type `T`.
907
 
908
  A type `X` satisfying any of the iterator requirements (
909
  [[iterator.requirements]]) satisfies the requirements of
910
  `ValueSwappable` if, for any dereferenceable object `x` of type `X`,
911
  `*x` is swappable.
912
 
 
 
913
  User code can ensure that the evaluation of `swap` calls is performed in
914
  an appropriate context under the various conditions as follows:
915
 
916
  ``` cpp
917
  #include <utility>
@@ -924,11 +948,11 @@ void value_swap(T&& t, U&& u) {
924
  // for rvalues and lvalues
925
  }
926
 
927
  // Requires: lvalues of T shall be swappable.
928
  template <class T>
929
- void lv_swap(T& t1 T& t2) {
930
  using std::swap;
931
  swap(t1, t2); // OK: uses swappable conditions for
932
  } // lvalues of type T
933
 
934
  namespace N {
@@ -952,48 +976,52 @@ int main() {
952
  value_swap(a1, proxy(a2));
953
  assert(a1.m == -5 && a2.m == 5);
954
  }
955
  ```
956
 
 
 
957
  #### `NullablePointer` requirements <a id="nullablepointer.requirements">[[nullablepointer.requirements]]</a>
958
 
959
  A `NullablePointer` type is a pointer-like type that supports null
960
  values. A type `P` meets the requirements of `NullablePointer` if:
961
 
962
  - `P` satisfies the requirements of `EqualityComparable`,
963
  `DefaultConstructible`, `CopyConstructible`, `CopyAssignable`, and
964
  `Destructible`,
965
  - lvalues of type `P` are swappable ([[swappable.requirements]]),
966
- - the expressions shown in Table  [[nullablepointer]] are valid and have
967
- the indicated semantics, and
968
  - `P` satisfies all the other requirements of this subclause.
969
 
970
  A value-initialized object of type `P` produces the null value of the
971
  type. The null value shall be equivalent only to itself. A
972
  default-initialized object of type `P` may have an indeterminate value.
973
- Operations involving indeterminate values may cause undefined behavior.
 
 
974
 
975
  An object `p` of type `P` can be contextually converted to `bool`
976
  (Clause  [[conv]]). The effect shall be as if `p != nullptr` had been
977
  evaluated in place of `p`.
978
 
979
  No operation which is part of the `NullablePointer` requirements shall
980
  exit via an exception.
981
 
982
- In Table  [[nullablepointer]], `u` denotes an identifier, `t` denotes a
983
- non-`const` lvalue of type `P`, `a` and `b` denote values of type
984
- (possibly `const`) `P`, and `np` denotes a value of type (possibly
985
  `const`) `std::nullptr_t`.
986
 
987
  **Table: `NullablePointer` requirements** <a id="nullablepointer">[nullablepointer]</a>
988
 
989
  | | | |
990
- | -------------- | ---------------------------------- | ------------------------ |
991
- | `P u(np);`<br> | | post: `u == nullptr` |
992
  | `P u = np;` | | |
993
- | `P(np)` | | post: `P(np) == nullptr` |
994
- | `t = np` | `P&` | post: `t == nullptr` |
995
  | `a != b` | contextually convertible to `bool` | `!(a == b)` |
996
  | `a == np` | contextually convertible to `bool` | `a == P()` |
997
  | `np == a` | | |
998
  | `a != np` | contextually convertible to `bool` | `!(a == np)` |
999
  | `np != a` | | |
@@ -1004,25 +1032,21 @@ non-`const` lvalue of type `P`, `a` and `b` denote values of type
1004
  A type `H` meets the `Hash` requirements if:
1005
 
1006
  - it is a function object type ([[function.objects]]),
1007
  - it satisfies the requirements of `CopyConstructible` and
1008
  `Destructible` ([[utility.arg.requirements]]), and
1009
- - the expressions shown in Table  [[hash]] are valid and have the
1010
  indicated semantics.
1011
 
1012
  Given `Key` is an argument type for function objects of type `H`, in
1013
- Table  [[hash]] `h` is a value of type (possibly `const`) `H`, `u` is an
1014
- lvalue of type `Key`, and `k` is a value of a type convertible to
1015
  (possibly `const`) `Key`.
1016
 
1017
- **Table: `Hash` requirements** <a id="hash">[hash]</a>
1018
-
1019
- | | | |
1020
- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1021
- | `h(k)` | `size_t` | The value returned shall depend only on the argument `k` for the duration of the program. \enternote Thus all evaluations of the expression `h(k)` with the same value for `k` yield the same result for a given execution of the program. \exitnote \enternote For two different values `t1` and `t2`, the probability that `h(t1)` and `h(t2)` compare equal should be very small, approaching `1.0 / numeric_limits<size_t>::max()`. \exitnote |
1022
- | `h(u)` | `size_t` | Shall not modify `u`. |
1023
-
1024
 
1025
  #### Allocator requirements <a id="allocator.requirements">[[allocator.requirements]]</a>
1026
 
1027
  The library describes a standard set of requirements for *allocators*,
1028
  which are class-type objects that encapsulate the information about an
@@ -1032,12 +1056,12 @@ this allocation model, as well as the memory allocation and deallocation
1032
  primitives for it. All of the string types (Clause  [[strings]]),
1033
  containers (Clause  [[containers]]) (except array), string buffers and
1034
  string streams (Clause  [[input.output]]), and `match_results` (Clause 
1035
  [[re]]) are parameterized in terms of allocators.
1036
 
1037
- The template struct `allocator_traits` ([[allocator.traits]]) supplies
1038
- a uniform interface to all allocator types. Table  [[tab:desc.var.def]]
1039
  describes the types manipulated through allocators. Table 
1040
  [[tab:utilities.allocator.requirements]] describes the requirements on
1041
  allocator types and thus on types used to instantiate
1042
  `allocator_traits`. A requirement is optional if the last column of
1043
  Table  [[tab:utilities.allocator.requirements]] specifies a default for
@@ -1048,31 +1072,47 @@ of `allocator_traits` may provide different defaults and may provide
1048
  defaults for different requirements than the primary template. Within
1049
  Tables  [[tab:desc.var.def]] and 
1050
  [[tab:utilities.allocator.requirements]], the use of `move` and
1051
  `forward` always refers to `std::move` and `std::forward`, respectively.
1052
 
 
 
1053
  Note A: The member class template `rebind` in the table above is
1054
- effectively a typedef template. In general, if the name `Allocator` is
1055
- bound to `SomeAllocator<T>`, then `Allocator::rebind<U>::other` is the
1056
- same type as `SomeAllocator<U>`, where `SomeAllocator<T>::value_type` is
1057
- `T` and `SomeAllocator<U>::{}value_type` is `U`. If `Allocator` is a
1058
- class template instantiation of the form `SomeAllocator<T, Args>`, where
1059
- `Args` is zero or more type arguments, and `Allocator` does not supply a
1060
- `rebind` member template, the standard `allocator_traits` template uses
1061
- `SomeAllocator<U, Args>` in place of `Allocator::{}rebind<U>::other` by
1062
- default. For allocator types that are not template instantiations of the
1063
- above form, no default is provided.
 
 
 
 
 
 
 
 
 
 
 
 
 
1064
 
1065
  An allocator type `X` shall satisfy the requirements of
1066
  `CopyConstructible` ([[utility.arg.requirements]]). The `X::pointer`,
1067
  `X::const_pointer`, `X::void_pointer`, and `X::const_void_pointer` types
1068
  shall satisfy the requirements of `NullablePointer` (
1069
- [[nullablepointer.requirements]]). No constructor, comparison operator,
1070
- copy operation, move operation, or swap operation on these types shall
1071
- exit via an exception. `X::pointer` and `X::const_pointer` shall also
1072
- satisfy the requirements for a random access iterator (
1073
- [[iterator.requirements]]).
 
1074
 
1075
  Let `x1` and `x2` denote objects of (possibly different) types
1076
  `X::void_pointer`, `X::const_void_pointer`, `X::pointer`, or
1077
  `X::const_pointer`. Then, `x1` and `x2` are *equivalently-valued*
1078
  pointer values, if and only if both `x1` and `x2` can be explicitly
@@ -1106,15 +1146,18 @@ p1 - p2
1106
 
1107
  either or both objects may be replaced by an equivalently-valued object
1108
  of type `X::const_pointer` with no change in semantics.
1109
 
1110
  An allocator may constrain the types on which it can be instantiated and
1111
- the arguments for which its `construct` member may be called. If a type
1112
- cannot be used with a particular allocator, the allocator class or the
1113
- call to `construct` may fail to instantiate.
 
1114
 
1115
- the following is an allocator class template supporting the minimal
 
 
1116
  interface that satisfies the requirements of Table 
1117
  [[tab:utilities.allocator.requirements]]:
1118
 
1119
  ``` cpp
1120
  template <class Tp>
@@ -1132,15 +1175,29 @@ template <class T, class U>
1132
  bool operator==(const SimpleAllocator<T>&, const SimpleAllocator<U>&);
1133
  template <class T, class U>
1134
  bool operator!=(const SimpleAllocator<T>&, const SimpleAllocator<U>&);
1135
  ```
1136
 
 
 
1137
  If the alignment associated with a specific over-aligned type is not
1138
  supported by an allocator, instantiation of the allocator for that type
1139
  may fail. The allocator also may silently ignore the requested
1140
- alignment. Additionally, the member function `allocate` for that type
1141
- may fail by throwing an object of type `std::bad_alloc`.
 
 
 
 
 
 
 
 
 
 
 
 
1142
 
1143
  ### Constraints on programs <a id="constraints">[[constraints]]</a>
1144
 
1145
  #### Overview <a id="constraints.overview">[[constraints.overview]]</a>
1146
 
@@ -1161,20 +1218,21 @@ The behavior of a C++program is undefined if it adds declarations or
1161
  definitions to namespace `std` or to a namespace within namespace `std`
1162
  unless otherwise specified. A program may add a template specialization
1163
  for any standard library template to namespace `std` only if the
1164
  declaration depends on a user-defined type and the specialization meets
1165
  the standard library requirements for the original template and is not
1166
- explicitly prohibited.[^22]
1167
 
1168
  The behavior of a C++program is undefined if it declares
1169
 
1170
  - an explicit specialization of any member function of a standard
1171
  library class template, or
1172
  - an explicit specialization of any member function template of a
1173
  standard library class or class template, or
1174
  - an explicit or partial specialization of any member class template of
1175
- a standard library class or class template.
 
1176
 
1177
  A program may explicitly instantiate a template defined in the standard
1178
  library only if the declaration depends on the name of a user-defined
1179
  type and the instantiation meets the standard library requirements for
1180
  the original template.
@@ -1187,10 +1245,20 @@ namespace ([[namespace.def]]).
1187
  The behavior of a C++program is undefined if it adds declarations or
1188
  definitions to namespace `posix` or to a namespace within namespace
1189
  `posix` unless otherwise specified. The namespace `posix` is reserved
1190
  for use by ISO/IEC 9945 and other POSIX standards.
1191
 
 
 
 
 
 
 
 
 
 
 
1192
  #### Reserved names <a id="reserved.names">[[reserved.names]]</a>
1193
 
1194
  The C++standard library reserves the following kinds of names:
1195
 
1196
  - macros
@@ -1199,61 +1267,81 @@ The C++standard library reserves the following kinds of names:
1199
 
1200
  If a program declares or defines a name in a context where it is
1201
  reserved, other than as explicitly allowed by this Clause, its behavior
1202
  is undefined.
1203
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1204
  ##### Macro names <a id="macro.names">[[macro.names]]</a>
1205
 
1206
  A translation unit that includes a standard library header shall not
1207
  `#define` or `#undef` names declared in any standard library header.
1208
 
1209
  A translation unit shall not `#define` or `#undef` names lexically
1210
  identical to keywords, to the identifiers listed in Table 
1211
  [[tab:identifiers.special]], or to the *attribute-token*s described in 
1212
  [[dcl.attr]].
1213
 
1214
- ##### Global names <a id="global.names">[[global.names]]</a>
1215
-
1216
- Certain sets of names and function signatures are always reserved to the
1217
- implementation:
1218
-
1219
- - Each name that contains a double underscore `__` or begins with an
1220
- underscore followed by an uppercase letter ([[lex.key]]) is reserved
1221
- to the implementation for any use.
1222
- - Each name that begins with an underscore is reserved to the
1223
- implementation for use as a name in the global namespace.
1224
-
1225
  ##### External linkage <a id="extern.names">[[extern.names]]</a>
1226
 
1227
  Each name declared as an object with external linkage in a header is
1228
  reserved to the implementation to designate that library object with
1229
- external linkage, [^23] both in namespace `std` and in the global
1230
  namespace.
1231
 
1232
  Each global function signature declared with external linkage in a
1233
  header is reserved to the implementation to designate that function
1234
- signature with external linkage. [^24]
1235
 
1236
- Each name from the Standard C library declared with external linkage is
1237
  reserved to the implementation for use as a name with `extern "C"`
1238
- linkage, both in namespace std and in the global namespace.
1239
 
1240
- Each function signature from the Standard C library declared with
1241
  external linkage is reserved to the implementation for use as a function
1242
- signature with both `extern "C"` and `extern "C++"` linkage, [^25] or as
1243
  a name of namespace scope in the global namespace.
1244
 
1245
  ##### Types <a id="extern.types">[[extern.types]]</a>
1246
 
1247
- For each type T from the Standard C library,[^26] the types `::T` and
1248
  `std::T` are reserved to the implementation and, when defined, `::T`
1249
  shall be identical to `std::T`.
1250
 
1251
  ##### User-defined literal suffixes <a id="usrlit.suffix">[[usrlit.suffix]]</a>
1252
 
1253
- Literal suffix identifiers that do not start with an underscore are
1254
- reserved for future standardization.
1255
 
1256
  #### Headers <a id="alt.headers">[[alt.headers]]</a>
1257
 
1258
  If a file with a name equivalent to the derived file name for one of the
1259
  C++standard library headers is not provided as part of the
@@ -1273,55 +1361,73 @@ Clauses  [[language.support]] through  [[thread]] and Annex  [[depr]]
1273
  describe the behavior of numerous functions defined by the C++standard
1274
  library. Under some circumstances, however, certain of these function
1275
  descriptions also apply to replacement functions defined in the
1276
  program ([[definitions]]).
1277
 
1278
- A C++program may provide the definition for any of twelve dynamic memory
1279
- allocation function signatures declared in header `<new>` (
1280
  [[basic.stc.dynamic]], [[support.dynamic]]):
1281
 
1282
- - `operator new(std::size_t)`
1283
- - `operator new(std::size_t, const std::nothrow_t&)`
1284
- - `operator new[](std::size_t)`
1285
- - `operator new[](std::size_t, const std::nothrow_t&)`
1286
- - `operator delete(void*)`
1287
- - `operator delete(void*, const std::nothrow_t&)`
1288
- - `operator delete[](void*)`
1289
- - `operator delete[](void*, const std::nothrow_t&)`
1290
- - `operator delete(void*, std::size_t)`
1291
- - `operator delete(void*, std::size_t, const std::nothrow_t&)`
1292
- - `operator delete[](void*, std::size_t)`
1293
- - `operator delete[](void*, std::size_t, const std::nothrow_t&)`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1294
 
1295
  The program’s definitions are used instead of the default versions
1296
  supplied by the implementation ([[support.dynamic]]). Such replacement
1297
  occurs prior to program startup ([[basic.def.odr]], [[basic.start]]).
1298
- The program’s definitions shall not be specified as `inline`. No
1299
  diagnostic is required.
1300
 
1301
  #### Handler functions <a id="handler.functions">[[handler.functions]]</a>
1302
 
1303
- The C++standard library provides default versions of the following
1304
- handler functions (Clause  [[language.support]]):
1305
 
1306
- - `unexpected_handler`
1307
  - `terminate_handler`
1308
 
1309
  A C++program may install different handler functions during execution,
1310
  by supplying a pointer to a function defined in the program or the
1311
  library as an argument to (respectively):
1312
 
1313
  - `set_new_handler`
1314
- - `set_unexpected`
1315
- - `set_terminate` subclauses  [[alloc.errors]], Storage allocation
1316
- errors, and  [[support.exception]], Exception handling.
 
1317
 
1318
  A C++program can get a pointer to the current handler function by
1319
  calling the following functions:
1320
 
1321
  - `get_new_handler`
1322
- - `get_unexpected`
1323
  - `get_terminate`
1324
 
1325
  Calling the `set_*` and `get_*` functions shall not incur a data race. A
1326
  call to any of the `set_*` functions shall synchronize with subsequent
1327
  calls to the same `set_*` function and to the corresponding `get_*`
@@ -1330,26 +1436,26 @@ function.
1330
  #### Other functions <a id="res.on.functions">[[res.on.functions]]</a>
1331
 
1332
  In certain cases (replacement functions, handler functions, operations
1333
  on types used to instantiate standard library template components), the
1334
  C++standard library depends on components supplied by a C++program. If
1335
- these components do not meet their requirements, the Standard places no
1336
- requirements on the implementation.
1337
 
1338
  In particular, the effects are undefined in the following cases:
1339
 
1340
  - for replacement functions ([[new.delete]]), if the installed
1341
  replacement function does not implement the semantics of the
1342
  applicable *Required behavior:* paragraph.
1343
- - for handler functions ([[new.handler]], [[terminate.handler]],
1344
- [[unexpected.handler]]), if the installed handler function does not
1345
- implement the semantics of the applicable *Required behavior:*
1346
- paragraph
1347
  - for types used as template arguments when instantiating a template
1348
  component, if the operations on the type do not implement the
1349
- semantics of the applicable subclause ([[allocator.requirements]],
1350
- [[container.requirements]], [[iterator.requirements]],
 
1351
  [[numeric.requirements]]). Operations on such types can report a
1352
  failure by throwing an exception unless otherwise specified.
1353
  - if any replacement function or handler function or destructor
1354
  operation exits via an exception, unless specifically allowed in the
1355
  applicable *Required behavior:* paragraph.
@@ -1370,37 +1476,40 @@ the C++standard library, unless explicitly stated otherwise.
1370
  address computations and accesses to objects (that would be valid if
1371
  the pointer did point to the first element of such an array) are in
1372
  fact valid.
1373
  - If a function argument binds to an rvalue reference parameter, the
1374
  implementation may assume that this parameter is a unique reference to
1375
- this argument. If the parameter is a generic parameter of the form
1376
- `T&&` and an lvalue of type `A` is bound, the argument binds to an
1377
- lvalue reference ([[temp.deduct.call]]) and thus is not covered by
1378
- the previous sentence. If a program casts an lvalue to an xvalue while
1379
- passing that lvalue to a library function (e.g. by calling the
1380
- function with the argument `move(x)`), the program is effectively
1381
- asking that function to treat that lvalue as a temporary. The
1382
- implementation is free to optimize away aliasing checks which might be
1383
- needed if the argument was an lvalue.
 
1384
 
1385
- #### Shared objects and the library <a id="res.on.objects">[[res.on.objects]]</a>
1386
 
1387
  The behavior of a program is undefined if calls to standard library
1388
  functions from different threads may introduce a data race. The
1389
  conditions under which this may occur are specified in 
1390
- [[res.on.data.races]]. Modifying an object of a standard library type
1391
- that is shared between threads risks undefined behavior unless objects
1392
- of that type are explicitly specified as being sharable without data
1393
- races or the user supplies a locking mechanism.
1394
 
1395
- In particular, the program is required to ensure that completion of the
1396
- constructor of any object of a class type defined in the standard
1397
- library happens before any other member function invocation on that
1398
- object and, unless otherwise specified, to ensure that completion of any
1399
- member function invocation other than destruction on such an object
1400
- happens before destruction of that object. This applies even to objects
1401
- such as mutexes intended for thread synchronization.
 
 
 
 
 
1402
 
1403
  #### Requires paragraph <a id="res.on.required">[[res.on.required]]</a>
1404
 
1405
  Violation of the preconditions specified in a function’s *Requires:*
1406
  paragraph results in undefined behavior unless the function’s *Throws:*
@@ -1413,13 +1522,13 @@ violated.
1413
 
1414
  This section describes the constraints upon, and latitude of,
1415
  implementations of the C++standard library.
1416
 
1417
  An implementation’s use of headers is discussed in  [[res.on.headers]],
1418
- its use of macros in  [[res.on.macro.definitions]], global functions in 
1419
- [[global.functions]], member functions in  [[member.functions]], data
1420
- race avoidance in  [[res.on.data.races]], access specifiers in 
1421
  [[protection.within.classes]], class derivation in  [[derivation]], and
1422
  exceptions in  [[res.on.exception.handling]].
1423
 
1424
  #### Headers <a id="res.on.headers">[[res.on.headers]]</a>
1425
 
@@ -1432,12 +1541,13 @@ headers.
1432
  Certain types and macros are defined in more than one header. Every such
1433
  entity shall be defined such that any header that defines it may be
1434
  included after any other header that also defines it (
1435
  [[basic.def.odr]]).
1436
 
1437
- The C standard headers ([[depr.c.headers]]) shall include only their
1438
- corresponding C++standard header, as described in  [[headers]].
 
1439
 
1440
  #### Restrictions on macro definitions <a id="res.on.macro.definitions">[[res.on.macro.definitions]]</a>
1441
 
1442
  The names and global function signatures described in  [[contents]] are
1443
  reserved to the implementation.
@@ -1445,66 +1555,71 @@ reserved to the implementation.
1445
  All object-like macros defined by the C standard library and described
1446
  in this Clause as expanding to integral constant expressions are also
1447
  suitable for use in `#if` preprocessing directives, unless explicitly
1448
  stated otherwise.
1449
 
1450
- #### Global and non-member functions <a id="global.functions">[[global.functions]]</a>
1451
 
1452
- It is unspecified whether any global or non-member functions in the
1453
- C++standard library are defined as `inline` ([[dcl.fct.spec]]).
1454
 
1455
- A call to a global or non-member function signature described in
1456
- Clauses  [[language.support]] through  [[thread]] and Annex  [[depr]]
1457
- shall behave as if the implementation declared no additional global or
1458
- non-member function signatures.[^27]
1459
 
1460
- An implementation shall not declare a global or non-member function
1461
- signature with additional default arguments.
1462
 
1463
- Unless otherwise specified, global and non-member functions in the
1464
- standard library shall not use functions from another namespace which
1465
- are found through *argument-dependent name lookup* (
1466
- [[basic.lookup.argdep]]). The phrase “unless otherwise specified” is
1467
- intended to allow argument-dependent lookup in cases like that of
1468
- `ostream_iterator::operator=` ([[ostream.iterator.ops]]):
 
 
 
 
 
1469
 
1470
  *Effects:*
1471
 
1472
  ``` cpp
1473
  *out_stream << value;
1474
  if (delim != 0)
1475
  *out_stream << delim;
1476
  return *this;
1477
  ```
1478
 
 
 
1479
  #### Member functions <a id="member.functions">[[member.functions]]</a>
1480
 
1481
  It is unspecified whether any member functions in the C++standard
1482
- library are defined as `inline` ([[dcl.fct.spec]]).
1483
 
1484
- An implementation may declare additional non-virtual member function
1485
- signatures within a class:
 
 
 
1486
 
1487
- - by adding arguments with default values to a member function
1488
- signature; [^28] An implementation may not add arguments with default
1489
- values to virtual, global, or non-member functions.
1490
- - by replacing a member function signature with default values by two or
1491
- more member function signatures with equivalent behavior; and
1492
- - by adding a member function signature for a member function name.
1493
 
1494
- A call to a member function signature described in the C++standard
1495
- library behaves as if the implementation declares no additional member
1496
- function signatures.[^29]
1497
 
1498
- #### `constexpr` functions and constructors <a id="constexpr.functions">[[constexpr.functions]]</a>
1499
-
1500
- This standard explicitly requires that certain standard library
1501
- functions are `constexpr` ([[dcl.constexpr]]). An implementation shall
1502
- not declare any standard library function signature as `constexpr`
1503
- except for those where it is explicitly required. Within any header that
1504
- provides any non-defining declarations of `constexpr` functions or
1505
- constructors an implementation shall provide corresponding definitions.
1506
 
1507
  #### Requirements for stable algorithms <a id="algorithm.stable">[[algorithm.stable]]</a>
1508
 
1509
  When the requirements for an algorithm state that it is “stable” without
1510
  further elaboration, it means:
@@ -1518,12 +1633,12 @@ further elaboration, it means:
1518
  original order) precede the elements from the second range (preserving
1519
  their original order).
1520
 
1521
  #### Reentrancy <a id="reentrancy">[[reentrancy]]</a>
1522
 
1523
- Except where explicitly specified in this standard, it is
1524
- *implementation-defined* which functions in the Standard C++ library may
1525
  be recursively reentered.
1526
 
1527
  #### Data race avoidance <a id="res.on.data.races">[[res.on.data.races]]</a>
1528
 
1529
  This section specifies requirements that implementations shall meet to
@@ -1540,36 +1655,38 @@ via the function’s arguments, including `this`.
1540
  A C++standard library function shall not directly or indirectly modify
1541
  objects ([[intro.multithread]]) accessible by threads other than the
1542
  current thread unless the objects are accessed directly or indirectly
1543
  via the function’s non-const arguments, including `this`.
1544
 
1545
- This means, for example, that implementations can’t use a static object
1546
- for internal purposes without synchronization because it could cause a
1547
- data race even in programs that do not explicitly share objects between
1548
- threads.
1549
 
1550
  A C++standard library function shall not access objects indirectly
1551
  accessible via its arguments or via elements of its container arguments
1552
  except by invoking functions required by its specification on those
1553
  container elements.
1554
 
1555
  Operations on iterators obtained by calling a standard library container
1556
  or string member function may access the underlying container, but shall
1557
- not modify it. In particular, container operations that invalidate
 
 
1558
  iterators conflict with operations on iterators associated with that
1559
- container.
1560
 
1561
  Implementations may share their own internal objects between threads if
1562
  the objects are not visible to users and are protected against data
1563
  races.
1564
 
1565
  Unless otherwise specified, C++standard library functions shall perform
1566
  all operations solely within the current thread if those operations have
1567
  effects that are visible ([[intro.multithread]]) to users.
1568
 
1569
- This allows implementations to parallelize operations if there are no
1570
- visible side effects.
1571
 
1572
  #### Protection within classes <a id="protection.within.classes">[[protection.within.classes]]</a>
1573
 
1574
  It is unspecified whether any function signature or class described in
1575
  Clauses  [[language.support]] through  [[thread]] and Annex  [[depr]] is
@@ -1587,64 +1704,74 @@ through a hierarchy of base classes with names reserved to the
1587
  implementation.
1588
 
1589
  In any case:
1590
 
1591
  - Every base class described as `virtual` shall be virtual;
1592
- - Every base class described as non-`virtual` shall not be virtual;
1593
  - Unless explicitly stated otherwise, types with distinct names shall be
1594
- distinct types.[^30]
 
 
 
1595
 
1596
  #### Restrictions on exception handling <a id="res.on.exception.handling">[[res.on.exception.handling]]</a>
1597
 
1598
  Any of the functions defined in the C++standard library can report a
1599
- failure by throwing an exception of a type described in its paragraph.
1600
- An implementation may strengthen the *exception-specification* for a
1601
- non-virtual function by adding a non-throwing *noexcept-specification*.
 
1602
 
1603
- A function may throw an object of a type not listed in its clause if its
1604
- type is derived from a type named in the clause and would be caught by
1605
- an exception handler for the base type.
1606
-
1607
- Functions from the C standard library shall not throw exceptions [^31]
1608
  except when such a function calls a program-supplied function that
1609
- throws an exception.[^32]
1610
 
1611
  Destructor operations defined in the C++standard library shall not throw
1612
  exceptions. Every destructor in the C++standard library shall behave as
1613
- if it had a non-throwing exception specification. Any other functions
1614
- defined in the C++standard library that do not have an
1615
- *exception-specification* may throw *implementation-defined* exceptions
1616
- unless otherwise specified.[^33] An implementation may strengthen this
1617
- implicit *exception-specification* by adding an explicit one.[^34]
 
 
 
 
 
 
1618
 
1619
  #### Restrictions on storage of pointers <a id="res.on.pointer.storage">[[res.on.pointer.storage]]</a>
1620
 
1621
  Objects constructed by the standard library that may hold a
1622
  user-supplied pointer value or an integer of type `std::intptr_t` shall
1623
  store such values in a traceable pointer location (
1624
- [[basic.stc.dynamic.safety]]). Other libraries are strongly encouraged
1625
- to do the same, since not doing so may result in accidental use of
1626
- pointers that are not safely derived. Libraries that store pointers
1627
- outside the user’s address space should make it appear that they are
1628
- stored and retrieved from a traceable pointer location.
 
 
1629
 
1630
  #### Value of error codes <a id="value.error.codes">[[value.error.codes]]</a>
1631
 
1632
  Certain functions in the C++standard library report errors via a
1633
  `std::error_code` ([[syserr.errcode.overview]]) object. That object’s
1634
  `category()` member shall return `std::system_category()` for errors
1635
  originating from the operating system, or a reference to an
1636
  *implementation-defined* `error_category` object for errors originating
1637
  elsewhere. The implementation shall define the possible values of
1638
- `value()` for each of these error categories. For operating systems that
1639
- are based on POSIX, implementations are encouraged to define the
1640
- `std::system_category()` values as identical to the POSIX `errno`
1641
- values, with additional values as defined by the operating system’s
1642
- documentation. Implementations for operating systems that are not based
1643
- on POSIX are encouraged to define values identical to the operating
1644
- system’s values. For errors that do not originate from the operating
1645
- system, the implementation may provide enums for the associated values.
 
 
1646
 
1647
  #### Moved-from state of library types <a id="lib.types.movedfrom">[[lib.types.movedfrom]]</a>
1648
 
1649
  Objects of types defined in the C++standard library may be moved from (
1650
  [[class.copy]]). Move operations may be explicitly specified or
@@ -1654,18 +1781,21 @@ objects shall be placed in a valid but unspecified state.
1654
  <!-- Link reference definitions -->
1655
  [alg.c.library]: algorithms.md#alg.c.library
1656
  [alg.sorting]: algorithms.md#alg.sorting
1657
  [algorithm.stable]: #algorithm.stable
1658
  [algorithms]: algorithms.md#algorithms
 
1659
  [alloc.errors]: language.md#alloc.errors
1660
  [allocator.requirements]: #allocator.requirements
 
1661
  [allocator.traits]: utilities.md#allocator.traits
1662
  [alt.headers]: #alt.headers
1663
  [atomics]: atomics.md#atomics
1664
  [bad.alloc]: language.md#bad.alloc
1665
  [basic.def.odr]: basic.md#basic.def.odr
1666
  [basic.fundamental]: basic.md#basic.fundamental
 
1667
  [basic.link]: basic.md#basic.link
1668
  [basic.lookup.argdep]: basic.md#basic.lookup.argdep
1669
  [basic.scope.namespace]: basic.md#basic.scope.namespace
1670
  [basic.start]: basic.md#basic.start
1671
  [basic.stc.dynamic]: basic.md#basic.stc.dynamic
@@ -1674,10 +1804,11 @@ objects shall be placed in a valid but unspecified state.
1674
  [bitmask.types]: #bitmask.types
1675
  [byte.strings]: #byte.strings
1676
  [c.locales]: localization.md#c.locales
1677
  [c.strings]: strings.md#c.strings
1678
  [character.seq]: #character.seq
 
1679
  [class.copy]: special.md#class.copy
1680
  [class.ctor]: special.md#class.ctor
1681
  [class.dtor]: special.md#class.dtor
1682
  [class.mem]: class.md#class.mem
1683
  [class.mfct]: class.md#class.mfct
@@ -1698,49 +1829,50 @@ objects shall be placed in a valid but unspecified state.
1698
  [cstdint]: language.md#cstdint
1699
  [dcl.array]: dcl.md#dcl.array
1700
  [dcl.attr]: dcl.md#dcl.attr
1701
  [dcl.constexpr]: dcl.md#dcl.constexpr
1702
  [dcl.fct.default]: dcl.md#dcl.fct.default
1703
- [dcl.fct.spec]: dcl.md#dcl.fct.spec
1704
  [dcl.init]: dcl.md#dcl.init
 
 
1705
  [dcl.link]: dcl.md#dcl.link
1706
  [definitions]: #definitions
1707
- [defns.additional]: #defns.additional
1708
  [depr]: future.md#depr
1709
  [depr.c.headers]: future.md#depr.c.headers
 
 
1710
  [derivation]: #derivation
1711
  [derived.classes]: #derived.classes
1712
  [description]: #description
1713
- [destructible]: #destructible
1714
  [diagnostics]: diagnostics.md#diagnostics
1715
  [enumerated.types]: #enumerated.types
1716
- [equalitycomparable]: #equalitycomparable
1717
  [except]: except.md#except
 
 
 
1718
  [expr.delete]: expr.md#expr.delete
1719
  [expr.eq]: expr.md#expr.eq
1720
  [expr.new]: expr.md#expr.new
1721
  [expr.rel]: expr.md#expr.rel
1722
  [extern.names]: #extern.names
1723
  [extern.types]: #extern.types
1724
  [function.objects]: utilities.md#function.objects
1725
  [functions.within.classes]: #functions.within.classes
1726
  [global.functions]: #global.functions
1727
- [global.names]: #global.names
1728
  [handler.functions]: #handler.functions
1729
- [hash]: #hash
1730
  [hash.requirements]: #hash.requirements
1731
  [headers]: #headers
1732
  [input.output]: input.md#input.output
1733
  [intro.compliance]: intro.md#intro.compliance
1734
  [intro.defs]: intro.md#intro.defs
1735
  [intro.multithread]: intro.md#intro.multithread
1736
  [intro.refs]: intro.md#intro.refs
1737
  [iterator.requirements]: iterators.md#iterator.requirements
 
1738
  [iterators]: iterators.md#iterators
1739
  [language.support]: language.md#language.support
1740
  [lex]: lex.md#lex
1741
- [lex.key]: lex.md#lex.key
1742
  [lex.phases]: lex.md#lex.phases
1743
  [lib.types.movedfrom]: #lib.types.movedfrom
1744
  [library]: #library
1745
  [library.c]: #library.c
1746
  [library.general]: #library.general
@@ -1750,25 +1882,27 @@ objects shall be placed in a valid but unspecified state.
1750
  [member.functions]: #member.functions
1751
  [meta]: utilities.md#meta
1752
  [multibyte.strings]: #multibyte.strings
1753
  [namespace.constraints]: #namespace.constraints
1754
  [namespace.def]: dcl.md#namespace.def
 
1755
  [namespace.posix]: #namespace.posix
1756
  [namespace.std]: #namespace.std
1757
  [namespace.udecl]: dcl.md#namespace.udecl
1758
  [new.delete]: language.md#new.delete
1759
  [new.handler]: language.md#new.handler
1760
- [nullablepointer]: #nullablepointer
1761
  [nullablepointer.requirements]: #nullablepointer.requirements
1762
  [numeric.requirements]: numerics.md#numeric.requirements
1763
  [numerics]: numerics.md#numerics
1764
  [objects.within.classes]: #objects.within.classes
1765
  [organization]: #organization
1766
  [ostream.iterator.ops]: iterators.md#ostream.iterator.ops
 
1767
  [over.match]: over.md#over.match
1768
  [over.oper]: over.md#over.oper
1769
  [protection.within.classes]: #protection.within.classes
 
1770
  [re]: re.md#re
1771
  [reentrancy]: #reentrancy
1772
  [replacement.functions]: #replacement.functions
1773
  [requirements]: #requirements
1774
  [res.on.arguments]: #res.on.arguments
@@ -1799,164 +1933,151 @@ objects shall be placed in a valid but unspecified state.
1799
  [support.start.term]: language.md#support.start.term
1800
  [support.types]: language.md#support.types
1801
  [swappable.requirements]: #swappable.requirements
1802
  [syserr]: diagnostics.md#syserr
1803
  [syserr.errcode.overview]: diagnostics.md#syserr.errcode.overview
 
 
1804
  [tab:cpp.c.headers]: #tab:cpp.c.headers
1805
  [tab:cpp.headers.freestanding]: #tab:cpp.headers.freestanding
1806
  [tab:cpp.library.headers]: #tab:cpp.library.headers
1807
  [tab:desc.var.def]: #tab:desc.var.def
 
 
 
1808
  [tab:identifiers.special]: lex.md#tab:identifiers.special
1809
  [tab:library.categories]: #tab:library.categories
 
 
1810
  [tab:utilities.allocator.requirements]: #tab:utilities.allocator.requirements
1811
  [temp.deduct.call]: temp.md#temp.deduct.call
1812
  [template.bitset]: utilities.md#template.bitset
1813
  [terminate.handler]: language.md#terminate.handler
1814
  [thread]: thread.md#thread
1815
  [type.descriptions]: #type.descriptions
1816
  [type.descriptions.general]: #type.descriptions.general
1817
- [unexpected.handler]: future.md#unexpected.handler
1818
  [using]: #using
1819
  [using.headers]: #using.headers
1820
  [using.linkage]: #using.linkage
1821
  [using.overview]: #using.overview
1822
  [usrlit.suffix]: #usrlit.suffix
1823
  [utilities]: utilities.md#utilities
1824
  [utility]: utilities.md#utility
1825
  [utility.arg.requirements]: #utility.arg.requirements
1826
  [utility.requirements]: #utility.requirements
1827
  [value.error.codes]: #value.error.codes
 
1828
 
1829
- [^1]: This definition is taken from POSIX.
1830
-
1831
- [^2]: To save space, items that do not apply to a Clause are omitted.
1832
  For example, if a Clause does not specify any requirements, there
1833
  will be no “Requirements” subclause.
1834
 
1835
- [^3]: Although in some cases the code given is unambiguously the optimum
1836
  implementation.
1837
 
1838
- [^4]: To save space, items that do not apply to a class are omitted. For
1839
  example, if a class does not specify any comparison functions, there
1840
  will be no “Comparison functions” subclause.
1841
 
1842
- [^5]: To save space, items that do not apply to a function are omitted.
1843
  For example, if a function does not specify any further
1844
- preconditions, there will be no Requires paragraph.
1845
 
1846
- [^6]: This simplifies the presentation of complexity requirements in
1847
  some cases.
1848
 
1849
- [^7]: Examples from  [[utility.requirements]] include:
1850
  `EqualityComparable`, `LessThanComparable`, `CopyConstructible`.
1851
  Examples from  [[iterator.requirements]] include: `InputIterator`,
1852
- `ForwardIterator`, `Function`, `Predicate`.
1853
 
1854
- [^8]: Such as an integer type, with constant integer values (
1855
  [[basic.fundamental]]).
1856
 
1857
- [^9]: Note that this definition differs from the definition in ISO C
1858
- 7.1.1.
1859
 
1860
- [^10]: declared in `<clocale>` ([[c.locales]]).
1861
-
1862
- [^11]: Many of the objects manipulated by function signatures declared
1863
- in `<cstring>` ([[c.strings]]) are character sequences or NTBSs.
1864
- The size of some of these character sequences is limited by a length
1865
  value, maintained separately from the character sequence.
1866
 
1867
- [^12]: A string literal, such as `"abc"`, is a static NTBS.
1868
 
1869
- [^13]: An NTBSthat contains characters only from the basic execution
1870
  character set is also an NTMBS. Each multibyte character then
1871
  consists of a single byte.
1872
 
1873
- [^14]: The C standard library headers (Annex  [[depr.c.headers]]) also
1874
  define names within the global namespace, while the C++headers for C
1875
  library facilities ([[headers]]) may also define names within the
1876
  global namespace.
1877
 
1878
- [^15]: This gives implementers freedom to use inline namespaces to
1879
  support multiple configurations of the library.
1880
 
1881
- [^16]: A header is not necessarily a source file, nor are the sequences
1882
  delimited by `<` and `>` in header names necessarily valid source
1883
  file names ([[cpp.include]]).
1884
 
1885
- [^17]: This disallows the practice, allowed in C, of providing a masking
 
 
 
1886
  macro in addition to the function prototype. The only way to achieve
1887
  equivalent inline behavior in C++is to provide a definition as an
1888
  extern inline function.
1889
 
1890
- [^18]: In particular, including the standard header `<iso646.h>` or
1891
  `<ciso646>` has no effect.
1892
 
1893
- [^19]: The `".h"` headers dump all their names into the global
1894
  namespace, whereas the newer forms keep their names in namespace
1895
  `std`. Therefore, the newer forms are the preferred forms for all
1896
  uses except for C++programs which are intended to be strictly
1897
  compatible with C.
1898
 
1899
- [^20]: This is the same as the Standard C library.
1900
 
1901
- [^21]: The only reliable way to declare an object or function signature
1902
- from the Standard C library is by including the header that declares
1903
  it, notwithstanding the latitude granted in 7.1.4 of the C Standard.
1904
 
1905
- [^22]: Any library code that instantiates other library templates must
1906
  be prepared to work adequately with any user-supplied specialization
1907
- that meets the minimum requirements of the Standard.
1908
 
1909
- [^23]: The list of such reserved names includes `errno`, declared or
1910
  defined in `<cerrno>`.
1911
 
1912
- [^24]: The list of such reserved function signatures with external
1913
  linkage includes `setjmp(jmp_buf)`, declared or defined in
1914
  `<csetjmp>`, and `va_end(va_list)`, declared or defined in
1915
  `<cstdarg>`.
1916
 
1917
- [^25]: The function signatures declared in `<cuchar>`, `<cwchar>`, and
1918
  `<cwctype>` are always reserved, notwithstanding the restrictions
1919
  imposed in subclause 4.5.1 of Amendment 1 to the C Standard for
1920
  these headers.
1921
 
1922
- [^26]: These types are `clock_t`, `div_t`, `FILE`, `fpos_t`, `lconv`,
1923
  `ldiv_t`, `mbstate_t`, `ptrdiff_t`, `sig_atomic_t`, `size_t`,
1924
  `time_t`, `tm`, `va_list`, `wctrans_t`, `wctype_t`, and `wint_t`.
1925
 
1926
- [^27]: A valid C++program always calls the expected library global or
1927
- non-member function. An implementation may also define additional
1928
- global or non-member functions that would otherwise not be called by
1929
- a valid C++program.
1930
 
1931
- [^28]: Hence, the address of a member function of a class in the
1932
- C++standard library has an unspecified type.
1933
-
1934
- [^29]: A valid C++program always calls the expected library member
1935
- function, or one with equivalent behavior. An implementation may
1936
- also define additional member functions that would otherwise not be
1937
- called by a valid C++program.
1938
-
1939
- [^30]: There is an implicit exception to this rule for types that are
1940
  described as synonyms for basic integral types, such as `size_t` (
1941
  [[support.types]]) and `streamoff` ([[stream.types]]).
1942
 
1943
- [^31]: That is, the C library functions can all be treated as if they
1944
  are marked `noexcept`. This allows implementations to make
1945
  performance optimizations based on the absence of exceptions at
1946
  runtime.
1947
 
1948
- [^32]: The functions `qsort()` and `bsearch()` ([[alg.c.library]]) meet
1949
  this condition.
1950
 
1951
- [^33]: In particular, they can report a failure to allocate storage by
1952
  throwing an exception of type `bad_alloc`, or a class derived from
1953
- `bad_alloc` ([[bad.alloc]]). Library implementations should report
1954
- errors by throwing exceptions of or derived from the standard
1955
- exception classes ([[bad.alloc]], [[support.exception]],
1956
- [[std.exceptions]]).
1957
-
1958
- [^34]: That is, an implementation may provide an explicit
1959
- *exception-specification* that defines the subset of “any”
1960
- exceptions thrown by that function. This implies that the
1961
- implementation may list implementation-defined types in such an
1962
- *exception-specification*.
 
28
  exception classes.
29
 
30
  The general utilities library (Clause  [[utilities]]) includes
31
  components used by other library elements, such as a predefined storage
32
  allocator for dynamic storage management ([[basic.stc.dynamic]]), and
33
+ components used as infrastructure in C++programs, such as tuples,
34
  function wrappers, and time facilities.
35
 
36
  The strings library (Clause  [[strings]]) provides support for
37
  manipulating text represented as sequences of type `char`, sequences of
38
  type `char16_t`, sequences of type `char32_t`, sequences of type
 
73
 
74
  The C++standard library also makes available the facilities of the C
75
  standard library, suitably adjusted to ensure static type safety.
76
 
77
  The descriptions of many library functions rely on the C standard
78
+ library for the semantics of those functions. In some cases, the
79
+ signatures specified in this International Standard may be different
80
+ from the signatures in the C standard library, and additional overloads
81
+ may be declared in this International Standard, but the behavior and the
82
+ preconditions (including any preconditions implied by the use of an ISO
83
+ C `restrict` qualifier) are the same unless otherwise stated.
84
 
85
  ## Definitions <a id="definitions">[[definitions]]</a>
86
 
87
+ [*Note 1*: Clause [[intro.defs]] defines additional terms used
88
+ elsewhere in this International Standard. — *end note*]
89
 
90
  a stream (described in Clause  [[input.output]]) that can seek to any
91
  integral position within the length of the stream
 
92
 
93
+ [*Note 2*: Every arbitrary-positional stream is also a repositional
94
+ stream. — *end note*]
95
 
96
+ \defncontext{Clauses~ [[strings]], [[localization]], [[input.output]], and~ [[re]]}
97
+ any object which, when treated sequentially, can represent text
98
 
99
+ [*Note 3*: The term does not mean only `char`, `char16_t`, `char32_t`,
100
+ and `wchar_t` objects, but any value that can be represented by a type
101
+ that provides the definitions specified in these Clauses. *end note*]
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
  a class or a type used to represent a *character*
 
 
 
104
 
105
+ [*Note 4*: It is used for one of the template parameters of the string,
106
+ iostream, and regular expression class templates. A character container
107
+ type is a POD ([[basic.types]]) type. — *end note*]
108
 
109
  an operator function ([[over.oper]]) for any of the equality (
110
  [[expr.eq]]) or relational ([[expr.rel]]) operators
111
 
 
 
112
  a group of library entities directly related as members, parameters, or
113
  return types
 
 
 
114
 
115
+ [*Note 5*: For example, the class template `basic_string` and the
116
+ non-member function templates that operate on strings are referred to as
117
+ the *string component*. — *end note*]
118
+
119
+ an expression whose evaluation as subexpression of a
120
+ *conditional-expression* `CE` ([[expr.cond]]) would not prevent `CE`
121
+ from being a core constant expression ([[expr.const]])
122
 
123
  one or more threads are unable to continue execution because each is
124
  blocked waiting for one or more of the others to satisfy some condition
125
 
126
+ any specific behavior provided by the implementation, within the scope
127
+ of the *required behavior*
128
 
129
+ a description of *replacement function* and *handler function* semantics
 
130
 
131
+ a direct-initialization ([[dcl.init]]) that is not
132
+ list-initialization ([[dcl.init.list]])
 
 
 
 
133
 
134
  a *non-reserved function* whose definition may be provided by a
135
  C++program
 
 
 
 
136
 
137
+ [*Note 6*: A C++program may designate a handler function at various
138
+ points in its execution by supplying a pointer to the function when
139
+ calling any of the library functions that install handler functions
140
+ (Clause  [[language.support]]). — *end note*]
141
 
142
  templates, defined in Clause  [[input.output]], that take two template
143
  arguments
 
 
 
 
 
144
 
145
+ [*Note 7*: The arguments are named `charT` and `traits`. The argument
146
+ `charT` is a character container class, and the argument `traits` is a
147
+ class which defines additional characteristics and functions of the
148
+ character type represented by `charT` necessary to implement the
149
+ iostream class templates. — *end note*]
150
 
151
  a class member function ([[class.mfct]]) other than a constructor,
152
  assignment operator, or destructor that alters the state of an object of
153
  the class
154
 
 
 
 
 
 
 
 
155
  assignment of an rvalue of some object type to a modifiable lvalue of
156
  the same type
157
 
158
+ direct-initialization of an object of some type with an rvalue of the
159
+ same type
 
 
 
 
 
 
160
 
161
  a sequence of values that have *character type* that precede the
162
  terminating null character type value `charT()`
163
 
 
 
164
  a class member function ([[class.mfct]]) that accesses the state of an
165
  object of the class but does not alter that state
 
 
166
 
167
+ [*Note 8*: Observer functions are specified as `const` member
168
+ functions ([[class.this]]). — *end note*]
169
 
170
+ an object type, a function type that does not have cv-qualifiers or a
171
+ *ref-qualifier*, or a reference type
 
172
 
173
+ [*Note 9*: The term describes a type to which a reference can be
174
+ created, including reference types. — *end note*]
175
 
176
  a *non-reserved function* whose definition is provided by a C++program
 
 
 
 
177
 
178
+ [*Note 10*: Only one definition for such a function is in effect for
179
+ the duration of the program’s execution, as the result of creating the
180
+ program ([[lex.phases]]) and resolving the definitions of all
181
+ translation units ([[basic.link]]). — *end note*]
182
 
183
  a stream (described in Clause  [[input.output]]) that can seek to a
184
  position that was previously encountered
185
 
 
 
186
  a description of *replacement function* and *handler function* semantics
187
  applicable to both the behavior provided by the implementation and the
188
  behavior of any such function definition in the program
 
 
189
 
190
+ [*Note 11*: If such a function defined in a C++program fails to meet
191
+ the required behavior when it executes, the behavior is undefined.
192
+ — *end note*]
193
 
194
  a function, specified as part of the C++standard library, that must be
195
  defined by the implementation
 
 
196
 
197
+ [*Note 12*: If a C++program provides a definition for any reserved
198
+ function, the results are undefined. — *end note*]
199
 
200
  an algorithm that preserves, as appropriate to the particular algorithm,
201
  the order of elements
 
202
 
203
+ [*Note 13*: Requirements for stable algorithms are given in 
204
+ [[algorithm.stable]]. — *end note*]
205
 
206
  a class that encapsulates a set of types and functions necessary for
207
  class templates and function templates to manipulate objects of types
208
  for which they are instantiated
 
 
 
209
 
210
+ a value of an object that is not specified except that the object’s
 
 
 
 
 
 
211
  invariants are met and operations on the object behave as specified for
212
  its type
 
 
 
213
 
214
+ [*Example 1*: If an object `x` of type `std::vector<int>` is in a valid
215
+ but unspecified state, `x.empty()` can be called unconditionally, and
216
+ `x.front()` can be called only if `x.empty()` returns
217
+ `false`. — *end example*]
218
 
219
  ## Method of description (Informative) <a id="description">[[description]]</a>
220
 
221
  This subclause describes the conventions used to specify the C++standard
222
  library. [[structure]] describes the structure of the normative Clauses 
 
225
 
226
  ### Structure of each clause <a id="structure">[[structure]]</a>
227
 
228
  #### Elements <a id="structure.elements">[[structure.elements]]</a>
229
 
230
+ Each library clause contains the following elements, as applicable:[^1]
231
 
232
  - Summary
233
  - Requirements
234
  - Detailed specifications
235
+ - References to the C standard library
236
 
237
  #### Summary <a id="structure.summary">[[structure.summary]]</a>
238
 
239
  The Summary provides a synopsis of the category, and introduces the
240
  first-level subclauses. Each subclause also provides a summary, listing
 
268
  operations required of template arguments. They use a class template
269
  `char_traits` to define these constraints.
270
 
271
  Interface convention requirements are stated as generally as possible.
272
  Instead of stating “class X has to define a member function
273
+ `operator++()`”, the interface requires “for any object `x` of class
274
+ `X`, `++x` is defined”. That is, whether the operator is a member is
275
  unspecified.
276
 
277
  Requirements are stated in terms of well-defined expressions that define
278
  valid terms of the types that satisfy the requirements. For every set of
279
  well-defined expression requirements there is a table that specifies an
 
286
  [[type.descriptions]].
287
 
288
  In some cases the semantic requirements are presented as C++code. Such
289
  code is intended as a specification of equivalence of a construct to
290
  another construct, not necessarily as the way the construct must be
291
+ implemented.[^2]
292
 
293
  #### Detailed specifications <a id="structure.specifications">[[structure.specifications]]</a>
294
 
295
  The detailed specifications each contain the following elements:
296
 
297
  - name and brief description
298
+ - synopsis (class definition or function declaration, as appropriate)
299
  - restrictions on template arguments, if any
300
  - description of class invariants
301
  - description of function semantics
302
 
303
  Descriptions of class member functions follow the order (as
304
+ appropriate):[^3]
305
 
306
  - constructor(s) and destructor
307
  - copying, moving & assignment functions
308
  - comparison functions
309
  - modifier functions
310
  - observer functions
311
  - operators and other non-member functions
312
 
313
  Descriptions of function semantics contain the following elements (as
314
+ appropriate):[^4]
315
 
316
  - *Requires:* the preconditions for calling the function
317
  - *Effects:* the actions performed by the function
318
  - *Synchronization:* the synchronization operations (
319
  [[intro.multithread]]) applicable to the function
 
322
  - *Throws:* any exceptions thrown by the function, and the conditions
323
  that would cause the exception
324
  - *Complexity:* the time and/or space complexity of the function
325
  - *Remarks:* additional semantic constraints on the function
326
  - *Error conditions:* the error conditions for error codes reported by
327
+ the function
 
328
 
329
  Whenever the *Effects:* element specifies that the semantics of some
330
  function `F` are *Equivalent to* some code sequence, then the various
331
  elements are interpreted as follows. If `F`’s semantics specifies a
332
  *Requires:* element, then that requirement is logically imposed prior to
333
  the *equivalent-to* semantics. Next, the semantics of the code sequence
334
+ are determined by the *Requires:* , *Effects:* , *Synchronization:* ,
335
+ *Postconditions:* , *Returns:* , *Throws:* , *Complexity:* , *Remarks:*
336
+ , and *Error conditions:* specified for the function invocations
337
  contained in the code sequence. The value returned from `F` is specified
338
  by `F`’s *Returns:* element, or if `F` has no *Returns:* element, a
339
+ non-`void` return from `F` is specified by the `return` statements in
340
  the code sequence. If `F`’s semantics contains a *Throws:* ,
341
  *Postconditions:* , or *Complexity:* element, then that supersedes any
342
  occurrences of that element in the code sequence.
343
 
344
  For non-reserved replacement and handler functions, Clause 
 
349
  provided by either the implementation or a C++program. Where no
350
  distinction is explicitly made in the description, the behavior
351
  described is the required behavior.
352
 
353
  If the formulation of a complexity requirement calls for a negative
354
+ number of operations, the actual requirement is zero operations.[^5]
355
 
356
  Complexity requirements specified in the library clauses are upper
357
  bounds, and implementations that provide better complexity guarantees
358
  satisfy the requirements.
359
 
 
362
  `enum class errc` constants ([[syserr]]).
363
 
364
  #### C library <a id="structure.see.also">[[structure.see.also]]</a>
365
 
366
  Paragraphs labeled “” contain cross-references to the relevant portions
367
+ of this International Standard and the ISO C standard.
 
368
 
369
  ### Other conventions <a id="conventions">[[conventions]]</a>
370
 
371
  This subclause describes several editorial conventions used to describe
372
  the contents of the C++standard library. These conventions are for
 
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.[^6] These names are used in library
382
  Clauses to describe the types that may be supplied as arguments by a
383
  C++program when instantiating template components from the library.
384
 
385
  Certain types defined in Clause  [[input.output]] are used to describe
386
  implementation-defined types. They are based on other types, but with
387
  added constraints.
388
 
389
+ ##### Exposition-only types <a id="expos.only.types">[[expos.only.types]]</a>
390
+
391
+ Several types defined in Clauses  [[language.support]] through 
392
+ [[thread]] and Annex  [[depr]] that are used as function parameter or
393
+ return types are defined for the purpose of exposition only in order to
394
+ capture their language linkage. The declarations of such types are
395
+ followed by a comment ending in *exposition only*.
396
+
397
+ [*Example 1*:
398
+
399
+ ``` cpp
400
+ namespace std {
401
+ extern "C" using some-handler = int(int, void*, double); // exposition only
402
+ }
403
+ ```
404
+
405
+ The type placeholder `some-handler` can now be used to specify a
406
+ function that takes a callback parameter with C language linkage.
407
+
408
+ — *end example*]
409
+
410
  ##### Enumerated types <a id="enumerated.types">[[enumerated.types]]</a>
411
 
412
  Several types defined in Clause  [[input.output]] are *enumerated
413
  types*. Each enumerated type may be implemented as an enumeration or as
414
+ a synonym for an enumeration.[^7]
415
 
416
+ The enumerated type `enumerated` can be written:
417
 
418
  ``` cpp
419
+ enum enumerated { V₀, V₁, V₂, V₃, ..... };
420
 
421
+ inline const enumerated C₀(V₀);
422
+ inline const enumerated C₁(V₁);
423
+ inline const enumerated C₂(V₂);
424
+ inline const enumerated C₃(V₃);
425
  .....
426
  ```
427
 
428
+ Here, the names `C₀`, `C₁`, etc. represent *enumerated elements* for
429
  this particular enumerated type. All such elements have distinct values.
430
 
431
  ##### Bitmask types <a id="bitmask.types">[[bitmask.types]]</a>
432
 
433
  Several types defined in Clauses  [[language.support]] through 
 
437
 
438
  The bitmask type *bitmask* can be written:
439
 
440
  ``` cpp
441
  // For exposition only.
442
+ // int_type is an integral type capable of representing all values of the bitmask type.
 
443
  enum bitmask : int_type {
444
+ V₀ = 1 << 0, V₁ = 1 << 1, V₂ = 1 << 2, V₃ = 1 << 3, .....
445
  };
446
 
447
+ inline constexpr bitmask C₀(V₀{});
448
+ inline constexpr bitmask C₁(V₁{});
449
+ inline constexpr bitmask C₂(V₂{});
450
+ inline constexpr bitmask C₃(V₃{});
451
  .....
452
 
453
  constexpr bitmask{} operator&(bitmask{} X, bitmask{} Y) {
454
  return static_cast<bitmask{}>(
455
  static_cast<int_type>(X) & static_cast<int_type>(Y));
 
474
  bitmask{}& operator^=(bitmask{}& X, bitmask{} Y) {
475
  X = X ^ Y; return X;
476
  }
477
  ```
478
 
479
+ Here, the names `C₀`, `C₁`, etc. represent *bitmask elements* for this
480
  particular bitmask type. All such elements have distinct, nonzero values
481
+ such that, for any pair `Cᵢ` and `Cⱼ` where i j, `C_i & C_i` is
482
+ nonzero and `C_i & C_j` is zero. Additionally, the value `0` is used to
483
  represent an *empty bitmask*, in which no bitmask elements are set.
484
 
485
  The following terms apply to objects and values of bitmask types:
486
 
487
  - To *set* a value *Y* in an object *X* is to evaluate the expression
 
495
 
496
  The C standard library makes widespread use of characters and character
497
  sequences that follow a few uniform conventions:
498
 
499
  - A *letter* is any of the 26 lowercase or 26 uppercase letters in the
500
+ basic execution character set.
501
  - The *decimal-point character* is the (single-byte) character used by
502
  functions that convert between a (single-byte) character sequence and
503
  a value of one of the floating-point types. It is used in the
504
  character sequence to denote the beginning of a fractional part. It is
505
  represented in Clauses  [[language.support]] through  [[thread]] and
506
  Annex  [[depr]] by a period, `'.'`, which is also its value in the
507
  `"C"` locale, but may change during program execution by a call to
508
+ `setlocale(int, const char*)`,[^8] or by a change to a `locale`
509
  object, as described in Clauses  [[locales]] and  [[input.output]].
510
+ - A *character sequence* is an array object ([[dcl.array]]) `A` that
511
+ can be declared as `T A[N]`, where `T` is any of the types `char`,
512
  `unsigned char`, or `signed char` ([[basic.fundamental]]), optionally
513
  qualified by any combination of `const` or `volatile`. The initial
514
  elements of the array have defined contents up to and including an
515
  element determined by some predicate. A character sequence can be
516
+ designated by a pointer value `S` that points to its first element.
517
 
518
  ###### Byte strings <a id="byte.strings">[[byte.strings]]</a>
519
 
520
  A *null-terminated byte string*, or NTBS, is a character sequence whose
521
  highest-addressed element with defined content has the value zero (the
522
  *terminating null* character); no other element in the sequence has the
523
+ value zero. [^9]
524
 
525
  The *length* of an NTBS is the number of elements that precede the
526
  terminating null character. An *empty* NTBS has a length of zero.
527
 
528
  The *value* of an NTBS is the sequence of values of the elements up to
529
  and including the terminating null character.
530
 
531
+ A *static* NTBS is an NTBSwith static storage duration.[^10]
532
 
533
  ###### Multibyte strings <a id="multibyte.strings">[[multibyte.strings]]</a>
534
 
535
+ A *null-terminated multibyte string*, or NTMBS, is an NTBSthat
536
  constitutes a sequence of valid multibyte characters, beginning and
537
+ ending in the initial shift state.[^11]
538
 
539
  A *static* NTMBS is an NTMBSwith static storage duration.
540
 
541
  #### Functions within classes <a id="functions.within.classes">[[functions.within.classes]]</a>
542
 
543
  For the sake of exposition, Clauses  [[language.support]] through 
544
  [[thread]] and Annex  [[depr]] do not describe copy/move constructors,
545
  assignment operators, or (non-virtual) destructors with the same
546
  apparent semantics as those that can be generated by default (
547
+ [[class.ctor]], [[class.dtor]], [[class.copy]]). It is unspecified
548
+ whether the implementation provides explicit definitions for such member
549
+ function signatures, or for virtual destructors that can be generated by
550
+ default.
551
 
552
+ For the sake of exposition, the library clauses sometimes annotate
553
+ constructors with \EXPLICIT. Such a constructor is conditionally
554
+ declared as either explicit or non-explicit ([[class.conv.ctor]]).
555
+
556
+ [*Note 1*: This is typically implemented by declaring two such
557
+ constructors, of which at most one participates in overload
558
+ resolution. — *end note*]
559
 
560
  #### Private members <a id="objects.within.classes">[[objects.within.classes]]</a>
561
 
562
  Clauses  [[language.support]] through  [[thread]] and Annex  [[depr]] do
563
  not specify the representation of classes, and intentionally omit
564
  specification of class members ([[class.mem]]). An implementation may
565
  define static or non-static class members, or both, as needed to
566
  implement the semantics of the member functions specified in Clauses 
567
  [[language.support]] through  [[thread]] and Annex  [[depr]].
568
 
569
+ For the sake of exposition, some subclauses provide representative
570
+ declarations, and semantic requirements, for private members of classes
571
+ that meet the external specifications of the classes. The declarations
572
+ for such members are followed by a comment that ends with *exposition
573
+ only*, as in:
 
 
 
574
 
575
  ``` cpp
576
  streambuf* sb; // exposition only
577
  ```
578
 
579
  An implementation may use any technique that provides equivalent
580
+ observable behavior.
581
 
582
  ## Library-wide requirements <a id="requirements">[[requirements]]</a>
583
 
584
  This subclause specifies requirements that apply to the entire
585
  C++standard library. Clauses  [[language.support]] through  [[thread]]
 
596
  [[constraints]] describes constraints on well-formed C++programs, and
597
  [[conforming]] describes constraints on conforming implementations.
598
 
599
  ### Library contents and organization <a id="organization">[[organization]]</a>
600
 
601
+ [[contents]] describes the entities and macros defined in the
602
+ C++standard library. [[headers]] lists the standard library headers and
603
+ some constraints on those headers. [[compliance]] lists requirements for
604
+ a freestanding implementation of the C++ standard library.
605
 
606
  #### Library contents <a id="contents">[[contents]]</a>
607
 
608
+ The C++standard library provides definitions for the entities and macros
609
+ described in the synopses of the C++standard library headers (
610
+ [[headers]]).
611
 
612
+ All library entities except `operator new` and `operator delete` are
613
+ defined within the namespace `std` or namespaces nested within namespace
614
+ `std`.[^12] It is unspecified whether names declared in a specific
615
+ namespace are declared directly in that namespace or in an inline
616
+ namespace inside that namespace.[^13]
617
 
618
  Whenever a name `x` defined in the standard library is mentioned, the
619
  name `x` is assumed to be fully qualified as `::std::x`, unless
620
+ explicitly described otherwise. For example, if the *Effects:* section
621
+ for library function `F` is described as calling library function `G`,
622
+ the function `::std::G` is meant.
623
 
624
  #### Headers <a id="headers">[[headers]]</a>
625
 
626
  Each element of the C++standard library is declared or defined (as
627
+ appropriate) in a *header*.[^14]
628
 
629
+ The C++standard library provides the *C++library headers*, shown in
630
  Table  [[tab:cpp.library.headers]].
631
 
632
  **Table: C++library headers** <a id="tab:cpp.library.headers">[tab:cpp.library.headers]</a>
633
 
634
+ | | | | |
635
+ | ---------------------- | -------------------- | -------------------- | ----------------- |
636
+ | `<algorithm>` | `<future>` | `<numeric>` | `<strstream>` |
637
+ | `<any>` | `<initializer_list>` | `<optional>` | `<system_error>` |
638
+ | `<array>` | `<iomanip>` | `<ostream>` | `<thread>` |
639
+ | `<atomic>` | `<ios>` | `<queue>` | `<tuple>` |
640
+ | `<bitset>` | `<iosfwd>` | `<random>` | `<type_traits>` |
641
+ | `<chrono>` | `<iostream>` | `<ratio>` | `<typeindex>` |
642
+ | `<codecvt>` | `<istream>` | `<regex>` | `<typeinfo>` |
643
+ | `<complex>` | `<iterator>` | `<scoped_allocator>` | `<unordered_map>` |
644
+ | `<condition_variable>` | `<limits>` | `<set>` | `<unordered_set>` |
645
+ | `<deque>` | `<list>` | `<shared_mutex>` | `<utility>` |
646
+ | `<exception>` | `<locale>` | `<sstream>` | `<valarray>` |
647
+ | `<execution>` | `<map>` | `<stack>` | `<variant>` |
648
+ | `<filesystem>` | `<memory>` | `<stdexcept>` | `<vector>` |
649
+ | `<forward_list>` | `<memory_resource>` | `<streambuf>` | |
650
+ | `<fstream>` | `<mutex>` | `<string>` | |
651
+ | `<functional>` | `<new>` | `<string_view>` | |
652
 
653
 
654
+ The facilities of the C standard library are provided in the additional
655
+ headers shown in Table  [[tab:cpp.c.headers]]. [^15]
656
 
657
  **Table: C++headers for C library facilities** <a id="tab:cpp.c.headers">[tab:cpp.c.headers]</a>
658
 
659
  | | | | | |
660
  | ------------ | ------------- | ------------- | ----------- | ----------- |
 
664
  | `<cerrno>` | `<clocale>` | `<cstdbool>` | `<ctgmath>` | |
665
  | `<cfenv>` | `<cmath>` | `<cstddef>` | `<ctime>` | |
666
  | `<cfloat>` | `<csetjmp>` | `<cstdint>` | `<cuchar>` | |
667
 
668
 
669
+ Except as noted in Clauses  [[library]] through  [[thread]] and Annex 
670
+ [[depr]], the contents of each header `cname` is the same as that of the
671
+ corresponding header `name.h` as specified in the C standard library
672
+ (Clause  [[intro.refs]]). In the C++standard library, however, the
 
673
  declarations (except for names which are defined as macros in C) are
674
  within namespace scope ([[basic.scope.namespace]]) of the namespace
675
+ `std`. It is unspecified whether these names (including any overloads
676
+ added in Clauses  [[language.support]] through  [[thread]] and Annex 
677
+ [[depr]]) are first declared within the global namespace scope and are
678
+ then injected into namespace `std` by explicit *using-declaration*s (
679
+ [[namespace.udecl]]).
680
 
681
  Names which are defined as macros in C shall be defined as macros in the
682
  C++ standard library, even if C grants license for implementation as
683
+ functions.
684
+
685
+ [*Note 1*: The names defined as macros in C include the following:
686
+ `assert`, `offsetof`, `setjmp`, `va_arg`, `va_end`, and
687
+ `va_start`. — *end note*]
688
 
689
  Names that are defined as functions in C shall be defined as functions
690
+ in the C++standard library.[^16]
691
 
692
  Identifiers that are keywords or operators in C++shall not be defined as
693
+ macros in C++standard library headers.[^17]
694
 
695
  [[depr.c.headers]], C standard library headers, describes the effects of
696
+ using the `name.h` (C header) form in a C++program.[^18]
697
+
698
+ Annex K of the C standard describes a large number of functions, with
699
+ associated types and macros, which “promote safer, more secure
700
+ programming” than many of the traditional C library functions. The names
701
+ of the functions have a suffix of `_s`; most of them provide the same
702
+ service as the C library function with the unsuffixed name, but
703
+ generally take an additional argument whose value is the size of the
704
+ result array. If any C++header is included, it is
705
+ *implementation-defined* whether any of these names is declared in the
706
+ global namespace. (None of them is declared in namespace `std`.)
707
+
708
+ Table  [[tab:c.annex.k.names]] lists the Annex K names that may be
709
+ declared in some header. These names are also subject to the
710
+ restrictions of  [[macro.names]].
711
+
712
+ **Table: C standard Annex K names** <a id="tab:c.annex.k.names">[tab:c.annex.k.names]</a>
713
+
714
+ | | | | |
715
+ | ---------------------- | -------------------------- | -------------- | ------------- |
716
+ | `abort_handler_s` | `mbstowcs_s` | `strncat_s` | `vswscanf_s` |
717
+ | `asctime_s` | `memcpy_s` | `strncpy_s` | `vwprintf_s` |
718
+ | `bsearch_s` | `memmove_s` | `strtok_s` | `vwscanf_s` |
719
+ | `constraint_handler_t` | `memset_s` | `swprintf_s` | `wcrtomb_s` |
720
+ | `ctime_s` | `printf_s` | `swscanf_s` | `wcscat_s` |
721
+ | `errno_t` | `qsort_s` | `tmpfile_s` | `wcscpy_s` |
722
+ | `fopen_s` | `RSIZE_MAX` | `TMP_MAX_S` | `wcsncat_s` |
723
+ | `fprintf_s` | `rsize_t` | `tmpnam_s` | `wcsncpy_s` |
724
+ | `freopen_s` | `scanf_s` | `vfprintf_s` | `wcsnlen_s` |
725
+ | `fscanf_s` | `set_constraint_handler_s` | `vfscanf_s` | `wcsrtombs_s` |
726
+ | `fwprintf_s` | `snprintf_s` | `vfwprintf_s` | `wcstok_s` |
727
+ | `fwscanf_s` | `snwprintf_s` | `vfwscanf_s` | `wcstombs_s` |
728
+ | `getenv_s` | `sprintf_s` | `vprintf_s` | `wctomb_s` |
729
+ | `gets_s` | `sscanf_s` | `vscanf_s` | `wmemcpy_s` |
730
+ | `gmtime_s` | `strcat_s` | `vsnprintf_s` | `wmemmove_s` |
731
+ | `ignore_handler_s` | `strcpy_s` | `vsnwprintf_s` | `wprintf_s` |
732
+ | `L_tmpnam_s` | `strerror_s` | `vsprintf_s` | `wscanf_s` |
733
+ | `localtime_s` | `strerrorlen_s` | `vsscanf_s` | |
734
+ | `mbsrtowcs_s` | `strlen_s` | `vswprintf_s` | |
735
+
736
 
737
  #### Freestanding implementations <a id="compliance">[[compliance]]</a>
738
 
739
  Two kinds of implementations are defined: *hosted* and *freestanding* (
740
  [[intro.compliance]]). For a hosted implementation, this International
 
745
  [[tab:cpp.headers.freestanding]].
746
 
747
  **Table: C++headers for freestanding implementations** <a id="tab:cpp.headers.freestanding">[tab:cpp.headers.freestanding]</a>
748
 
749
  | Subclause | | Header |
750
+ | --------------------------------------------- | ------------------------- | --------------------------------- |
751
  | | | `<ciso646>` |
752
  | [[support.types]] | Types | `<cstddef>` |
753
  | [[support.limits]] | Implementation properties | `<cfloat>` `<limits>` `<climits>` |
754
  | [[cstdint]] | Integer types | `<cstdint>` |
755
  | [[support.start.term]] | Start and termination | `<cstdlib>` |
756
  | [[support.dynamic]] | Dynamic memory management | `<new>` |
757
  | [[support.rtti]] | Type identification | `<typeinfo>` |
758
  | [[support.exception]] | Exception handling | `<exception>` |
759
  | [[support.initlist]] | Initializer lists | `<initializer_list>` |
760
+ | [[support.runtime]] | Other runtime support | `<cstdarg>` |
761
  | [[meta]] | Type traits | `<type_traits>` |
762
  | [[atomics]] | Atomics | `<atomic>` |
763
+ | [[depr.cstdalign.syn]], [[depr.cstdbool.syn]] | Deprecated headers | `<cstdalign>` `<cstdbool>` |
764
 
765
 
766
  The supplied version of the header `<cstdlib>` shall declare at least
767
  the functions `abort`, `atexit`, `at_quick_exit`, `exit`, and
768
  `quick_exit` ([[support.start.term]]). The other headers listed in this
 
785
 
786
  A translation unit may include library headers in any order (Clause 
787
  [[lex]]). Each may be included more than once, with no effect different
788
  from being included exactly once, except that the effect of including
789
  either `<cassert>` or `<assert.h>` depends each time on the lexically
790
+ current definition of `NDEBUG`.[^19]
791
 
792
+ A translation unit shall include a header only outside of any
793
  declaration or definition, and shall include the header lexically before
794
  the first reference in that translation unit to any of the entities
795
  declared in that header. No diagnostic is required.
796
 
797
  #### Linkage <a id="using.linkage">[[using.linkage]]</a>
 
801
  the default `extern "C++"` linkage ([[dcl.link]]).
802
 
803
  Whether a name from the C standard library declared with external
804
  linkage has `extern "C"` or `extern "C++"` linkage is
805
  *implementation-defined*. It is recommended that an implementation use
806
+ `extern "C++"` linkage for this purpose.[^20]
807
 
808
  Objects and functions defined in the library and required by a
809
  C++program are included in the program prior to program startup.
810
 
811
+ See also replacement functions ([[replacement.functions]]), runtime
812
+ changes ([[handler.functions]]).
813
 
814
  ### Requirements on types and expressions <a id="utility.requirements">[[utility.requirements]]</a>
815
 
816
  [[utility.arg.requirements]] describes requirements on types and
817
  expressions used to instantiate templates defined in the C++standard
 
824
  allocators.
825
 
826
  #### Template argument requirements <a id="utility.arg.requirements">[[utility.arg.requirements]]</a>
827
 
828
  The template definitions in the C++standard library refer to various
829
+ named requirements whose details are set out in Tables 
830
+ [[tab:equalitycomparable]]– [[tab:destructible]]. In these tables, `T`
831
+ is an object or reference type to be supplied by a C++program
832
+ instantiating a template; `a`, `b`, and `c` are values of type (possibly
833
+ `const`) `T`; `s` and `t` are modifiable lvalues of type `T`; `u`
834
+ denotes an identifier; `rv` is an rvalue of type `T`; and `v` is an
835
+ lvalue of type (possibly `const`) `T` or an rvalue of type `const T`.
836
 
837
  In general, a default constructor is not required. Certain container
838
  class member function signatures specify `T()` as a default argument.
839
  `T()` shall be a well-defined expression ([[dcl.init]]) if one of those
840
  signatures is called using the default argument ([[dcl.fct.default]]).
841
 
842
  **Table: `EqualityComparable` requirements** <a id="equalitycomparable">[equalitycomparable]</a>
843
 
844
+ | Expression | Return type |
845
+ | ---------- | ----------- |
846
  | `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`. |
847
 
848
  **Table: `LessThanComparable` requirements** <a id="lessthancomparable">[lessthancomparable]</a>
849
 
850
+ | Expression | Return type | Requirement |
851
+ | ---------- | --------------------- | --------------------------------------------------------- |
852
  | `a < b` | convertible to `bool` | `<` is a strict weak ordering relation~([[alg.sorting]]) |
853
 
854
  **Table: `DefaultConstructible` requirements** <a id="defaultconstructible">[defaultconstructible]</a>
855
 
856
+ | Expression | Post-condition |
857
+ | -------------- | ------------------------------------------------------------------- |
858
  | `T t;` | object `t` is default-initialized |
859
+ | `T u{};` | object `u` is value-initialized or aggregate-initialized |
860
+ | `T()`<br>`T{}` | an object of type `T` is value-initialized or aggregate-initialized |
 
861
 
862
+ [*Note 1*: `rv` must still meet the requirements of the library
863
+ component that is using it. The operations listed in those requirements
864
+ must work as specified whether `rv` has been moved from or
865
+ not. *end note*]
 
 
 
866
 
867
  **Table: `CopyConstructible` requirements (in addition to `MoveConstructible`)** <a id="copyconstructible">[copyconstructible]</a>
868
 
869
+ | Expression | Post-condition |
870
  | ---------- | --------------------------------------------------------- |
871
  | `T u = v;` | the value of `v` is unchanged and is equivalent to ` u` |
872
  | `T(v)` | the value of `v` is unchanged and is equivalent to `T(v)` |
873
 
874
+ [*Note 2*:  `rv` must still meet the requirements of the library
875
+ component that is using it, whether or not `t` and `rv` refer to the
876
+ same object. The operations listed in those requirements must work as
877
+ specified whether `rv` has been moved from or not. — *end note*]
 
 
878
 
879
  **Table: `CopyAssignable` requirements (in addition to `MoveAssignable`)** <a id="copyassignable">[copyassignable]</a>
880
 
881
+ | Expression | Return type | Return value | Post-condition |
882
+ | ---------- | ----------- | ------------ | ------------------------------------------------------- |
883
  | `t = v` | `T&` | `t` | `t` is equivalent to `v`, the value of `v` is unchanged |
884
 
885
 
886
  **Table: `Destructible` requirements** <a id="destructible">[destructible]</a>
887
 
888
+ | Expression | Post-condition |
889
+ | ---------- | --------------------------------------------------------------------- |
890
  | `u.~T()` | All resources owned by `u` are reclaimed, no exception is propagated. |
891
 
892
 
893
  #### `Swappable` requirements <a id="swappable.requirements">[[swappable.requirements]]</a>
894
 
 
912
  - the two `swap` function templates defined in `<utility>` (
913
  [[utility]]) and
914
  - the lookup set produced by argument-dependent lookup (
915
  [[basic.lookup.argdep]]).
916
 
917
+ [*Note 1*: If `T` and `U` are both fundamental types or arrays of
918
+ fundamental types and the declarations from the header `<utility>` are
919
+ in scope, the overall lookup set described above is equivalent to that
920
+ of the qualified name lookup applied to the expression `std::swap(t, u)`
921
+ or `std::swap(u, t)` as appropriate. — *end note*]
922
 
923
+ [*Note 2*: It is unspecified whether a library component that has a
924
+ swappable requirement includes the header `<utility>` to ensure an
925
+ appropriate evaluation context. — *end note*]
926
 
927
  An rvalue or lvalue `t` is *swappable* if and only if `t` is swappable
928
  with any rvalue or lvalue, respectively, of type `T`.
929
 
930
  A type `X` satisfying any of the iterator requirements (
931
  [[iterator.requirements]]) satisfies the requirements of
932
  `ValueSwappable` if, for any dereferenceable object `x` of type `X`,
933
  `*x` is swappable.
934
 
935
+ [*Example 1*:
936
+
937
  User code can ensure that the evaluation of `swap` calls is performed in
938
  an appropriate context under the various conditions as follows:
939
 
940
  ``` cpp
941
  #include <utility>
 
948
  // for rvalues and lvalues
949
  }
950
 
951
  // Requires: lvalues of T shall be swappable.
952
  template <class T>
953
+ void lv_swap(T& t1, T& t2) {
954
  using std::swap;
955
  swap(t1, t2); // OK: uses swappable conditions for
956
  } // lvalues of type T
957
 
958
  namespace N {
 
976
  value_swap(a1, proxy(a2));
977
  assert(a1.m == -5 && a2.m == 5);
978
  }
979
  ```
980
 
981
+ — *end example*]
982
+
983
  #### `NullablePointer` requirements <a id="nullablepointer.requirements">[[nullablepointer.requirements]]</a>
984
 
985
  A `NullablePointer` type is a pointer-like type that supports null
986
  values. A type `P` meets the requirements of `NullablePointer` if:
987
 
988
  - `P` satisfies the requirements of `EqualityComparable`,
989
  `DefaultConstructible`, `CopyConstructible`, `CopyAssignable`, and
990
  `Destructible`,
991
  - lvalues of type `P` are swappable ([[swappable.requirements]]),
992
+ - the expressions shown in Table  [[tab:nullablepointer]] are valid and
993
+ have the indicated semantics, and
994
  - `P` satisfies all the other requirements of this subclause.
995
 
996
  A value-initialized object of type `P` produces the null value of the
997
  type. The null value shall be equivalent only to itself. A
998
  default-initialized object of type `P` may have an indeterminate value.
999
+
1000
+ [*Note 1*: Operations involving indeterminate values may cause
1001
+ undefined behavior. — *end note*]
1002
 
1003
  An object `p` of type `P` can be contextually converted to `bool`
1004
  (Clause  [[conv]]). The effect shall be as if `p != nullptr` had been
1005
  evaluated in place of `p`.
1006
 
1007
  No operation which is part of the `NullablePointer` requirements shall
1008
  exit via an exception.
1009
 
1010
+ In Table  [[tab:nullablepointer]], `u` denotes an identifier, `t`
1011
+ denotes a non-`const` lvalue of type `P`, `a` and `b` denote values of
1012
+ type (possibly `const`) `P`, and `np` denotes a value of type (possibly
1013
  `const`) `std::nullptr_t`.
1014
 
1015
  **Table: `NullablePointer` requirements** <a id="nullablepointer">[nullablepointer]</a>
1016
 
1017
  | | | |
1018
+ | -------------- | ---------------------------------- | ---------------------------------- |
1019
+ | `P u(np);`<br> | | Postconditions: `u == nullptr` |
1020
  | `P u = np;` | | |
1021
+ | `P(np)` | | Postconditions: `P(np) == nullptr` |
1022
+ | `t = np` | `P&` | Postconditions: `t == nullptr` |
1023
  | `a != b` | contextually convertible to `bool` | `!(a == b)` |
1024
  | `a == np` | contextually convertible to `bool` | `a == P()` |
1025
  | `np == a` | | |
1026
  | `a != np` | contextually convertible to `bool` | `!(a == np)` |
1027
  | `np != a` | | |
 
1032
  A type `H` meets the `Hash` requirements if:
1033
 
1034
  - it is a function object type ([[function.objects]]),
1035
  - it satisfies the requirements of `CopyConstructible` and
1036
  `Destructible` ([[utility.arg.requirements]]), and
1037
+ - the expressions shown in Table  [[tab:hash]] are valid and have the
1038
  indicated semantics.
1039
 
1040
  Given `Key` is an argument type for function objects of type `H`, in
1041
+ Table  [[tab:hash]] `h` is a value of type (possibly `const`) `H`, `u`
1042
+ is an lvalue of type `Key`, and `k` is a value of a type convertible to
1043
  (possibly `const`) `Key`.
1044
 
1045
+ [*Note 1*: Thus all evaluations of the expression `h(k)` with the same
1046
+ value for `k` yield the same result for a given execution of the
1047
+ program. — *end note*]
 
 
 
 
1048
 
1049
  #### Allocator requirements <a id="allocator.requirements">[[allocator.requirements]]</a>
1050
 
1051
  The library describes a standard set of requirements for *allocators*,
1052
  which are class-type objects that encapsulate the information about an
 
1056
  primitives for it. All of the string types (Clause  [[strings]]),
1057
  containers (Clause  [[containers]]) (except array), string buffers and
1058
  string streams (Clause  [[input.output]]), and `match_results` (Clause 
1059
  [[re]]) are parameterized in terms of allocators.
1060
 
1061
+ The class template `allocator_traits` ([[allocator.traits]]) supplies a
1062
+ uniform interface to all allocator types. Table  [[tab:desc.var.def]]
1063
  describes the types manipulated through allocators. Table 
1064
  [[tab:utilities.allocator.requirements]] describes the requirements on
1065
  allocator types and thus on types used to instantiate
1066
  `allocator_traits`. A requirement is optional if the last column of
1067
  Table  [[tab:utilities.allocator.requirements]] specifies a default for
 
1072
  defaults for different requirements than the primary template. Within
1073
  Tables  [[tab:desc.var.def]] and 
1074
  [[tab:utilities.allocator.requirements]], the use of `move` and
1075
  `forward` always refers to `std::move` and `std::forward`, respectively.
1076
 
1077
+ [*Note 1*: If `n == 0`, the return value is unspecified. — *end note*]
1078
+
1079
  Note A: The member class template `rebind` in the table above is
1080
+ effectively a typedef template.
1081
+
1082
+ [*Note 2*: In general, if the name `Allocator` is bound to
1083
+ `SomeAllocator<T>`, then `Allocator::rebind<U>::other` is the same type
1084
+ as `SomeAllocator<U>`, where `SomeAllocator<T>::value_type` is `T` and
1085
+ `SomeAllocator<U>::{}value_type` is `U`. *end note*]
1086
+
1087
+ If `Allocator` is a class template instantiation of the form
1088
+ `SomeAllocator<T, Args>`, where `Args` is zero or more type arguments,
1089
+ and `Allocator` does not supply a `rebind` member template, the standard
1090
+ `allocator_traits` template uses `SomeAllocator<U, Args>` in place of
1091
+ `Allocator::{}rebind<U>::other` by default. For allocator types that are
1092
+ not template instantiations of the above form, no default is provided.
1093
+
1094
+ Note B: If `X::propagate_on_container_copy_assignment::value` is `true`,
1095
+ `X` shall satisfy the `CopyAssignable` requirements (Table 
1096
+ [[tab:copyassignable]]) and the copy operation shall not throw
1097
+ exceptions. If `X::propagate_on_container_move_assignment::value` is
1098
+ `true`, `X` shall satisfy the `MoveAssignable` requirements (Table 
1099
+ [[tab:moveassignable]]) and the move operation shall not throw
1100
+ exceptions. If `X::propagate_on_container_swap::value` is `true`,
1101
+ lvalues of type `X` shall be swappable ([[swappable.requirements]]) and
1102
+ the `swap` operation shall not throw exceptions.
1103
 
1104
  An allocator type `X` shall satisfy the requirements of
1105
  `CopyConstructible` ([[utility.arg.requirements]]). The `X::pointer`,
1106
  `X::const_pointer`, `X::void_pointer`, and `X::const_void_pointer` types
1107
  shall satisfy the requirements of `NullablePointer` (
1108
+ [[nullablepointer.requirements]]). No constructor, comparison function,
1109
+ copy operation, move operation, or swap operation on these pointer types
1110
+ shall exit via an exception. `X::pointer` and `X::const_pointer` shall
1111
+ also satisfy the requirements for a random access iterator (
1112
+ [[random.access.iterators]]) and of a contiguous iterator (
1113
+ [[iterator.requirements.general]]).
1114
 
1115
  Let `x1` and `x2` denote objects of (possibly different) types
1116
  `X::void_pointer`, `X::const_void_pointer`, `X::pointer`, or
1117
  `X::const_pointer`. Then, `x1` and `x2` are *equivalently-valued*
1118
  pointer values, if and only if both `x1` and `x2` can be explicitly
 
1146
 
1147
  either or both objects may be replaced by an equivalently-valued object
1148
  of type `X::const_pointer` with no change in semantics.
1149
 
1150
  An allocator may constrain the types on which it can be instantiated and
1151
+ the arguments for which its `construct` or `destroy` members may be
1152
+ called. If a type cannot be used with a particular allocator, the
1153
+ allocator class or the call to `construct` or `destroy` may fail to
1154
+ instantiate.
1155
 
1156
+ [*Example 1*:
1157
+
1158
+ The following is an allocator class template supporting the minimal
1159
  interface that satisfies the requirements of Table 
1160
  [[tab:utilities.allocator.requirements]]:
1161
 
1162
  ``` cpp
1163
  template <class Tp>
 
1175
  bool operator==(const SimpleAllocator<T>&, const SimpleAllocator<U>&);
1176
  template <class T, class U>
1177
  bool operator!=(const SimpleAllocator<T>&, const SimpleAllocator<U>&);
1178
  ```
1179
 
1180
+ — *end example*]
1181
+
1182
  If the alignment associated with a specific over-aligned type is not
1183
  supported by an allocator, instantiation of the allocator for that type
1184
  may fail. The allocator also may silently ignore the requested
1185
+ alignment.
1186
+
1187
+ [*Note 3*: Additionally, the member function `allocate` for that type
1188
+ may fail by throwing an object of type `bad_alloc`. — *end note*]
1189
+
1190
+ ##### Allocator completeness requirements <a id="allocator.requirements.completeness">[[allocator.requirements.completeness]]</a>
1191
+
1192
+ If `X` is an allocator class for type `T`, `X` additionally satisfies
1193
+ the allocator completeness requirements if, whether or not `T` is a
1194
+ complete type:
1195
+
1196
+ - `X` is a complete type, and
1197
+ - all the member types of `allocator_traits<X>` ([[allocator.traits]])
1198
+ other than `value_type` are complete types.
1199
 
1200
  ### Constraints on programs <a id="constraints">[[constraints]]</a>
1201
 
1202
  #### Overview <a id="constraints.overview">[[constraints.overview]]</a>
1203
 
 
1218
  definitions to namespace `std` or to a namespace within namespace `std`
1219
  unless otherwise specified. A program may add a template specialization
1220
  for any standard library template to namespace `std` only if the
1221
  declaration depends on a user-defined type and the specialization meets
1222
  the standard library requirements for the original template and is not
1223
+ explicitly prohibited.[^21]
1224
 
1225
  The behavior of a C++program is undefined if it declares
1226
 
1227
  - an explicit specialization of any member function of a standard
1228
  library class template, or
1229
  - an explicit specialization of any member function template of a
1230
  standard library class or class template, or
1231
  - an explicit or partial specialization of any member class template of
1232
+ a standard library class or class template, or
1233
+ - a deduction guide for any standard library class template.
1234
 
1235
  A program may explicitly instantiate a template defined in the standard
1236
  library only if the declaration depends on the name of a user-defined
1237
  type and the instantiation meets the standard library requirements for
1238
  the original template.
 
1245
  The behavior of a C++program is undefined if it adds declarations or
1246
  definitions to namespace `posix` or to a namespace within namespace
1247
  `posix` unless otherwise specified. The namespace `posix` is reserved
1248
  for use by ISO/IEC 9945 and other POSIX standards.
1249
 
1250
+ ##### Namespaces for future standardization <a id="namespace.future">[[namespace.future]]</a>
1251
+
1252
+ Top level namespaces with a name starting with `std` and followed by a
1253
+ non-empty sequence of digits are reserved for future standardization.
1254
+ The behavior of a C++program is undefined if it adds declarations or
1255
+ definitions to such a namespace.
1256
+
1257
+ [*Example 1*: The top level namespace `std2` is reserved for use by
1258
+ future revisions of this International Standard. — *end example*]
1259
+
1260
  #### Reserved names <a id="reserved.names">[[reserved.names]]</a>
1261
 
1262
  The C++standard library reserves the following kinds of names:
1263
 
1264
  - macros
 
1267
 
1268
  If a program declares or defines a name in a context where it is
1269
  reserved, other than as explicitly allowed by this Clause, its behavior
1270
  is undefined.
1271
 
1272
+ ##### Zombie names <a id="zombie.names">[[zombie.names]]</a>
1273
+
1274
+ In namespace `std`, the following names are reserved for previous
1275
+ standardization:
1276
+
1277
+ - `auto_ptr`,
1278
+ - `binary_function`,
1279
+ - `bind1st`,
1280
+ - `bind2nd`,
1281
+ - `binder1st`,
1282
+ - `binder2nd`,
1283
+ - `const_mem_fun1_ref_t`,
1284
+ - `const_mem_fun1_t`,
1285
+ - `const_mem_fun_ref_t`,
1286
+ - `const_mem_fun_t`,
1287
+ - `get_unexpected`,
1288
+ - `mem_fun1_ref_t`,
1289
+ - `mem_fun1_t`,
1290
+ - `mem_fun_ref_t`,
1291
+ - `mem_fun_ref`,
1292
+ - `mem_fun_t`,
1293
+ - `mem_fun`,
1294
+ - `pointer_to_binary_function`,
1295
+ - `pointer_to_unary_function`,
1296
+ - `ptr_fun`,
1297
+ - `random_shuffle`,
1298
+ - `set_unexpected`,
1299
+ - `unary_function`,
1300
+ - `unexpected`, and
1301
+ - `unexpected_handler`.
1302
+
1303
  ##### Macro names <a id="macro.names">[[macro.names]]</a>
1304
 
1305
  A translation unit that includes a standard library header shall not
1306
  `#define` or `#undef` names declared in any standard library header.
1307
 
1308
  A translation unit shall not `#define` or `#undef` names lexically
1309
  identical to keywords, to the identifiers listed in Table 
1310
  [[tab:identifiers.special]], or to the *attribute-token*s described in 
1311
  [[dcl.attr]].
1312
 
 
 
 
 
 
 
 
 
 
 
 
1313
  ##### External linkage <a id="extern.names">[[extern.names]]</a>
1314
 
1315
  Each name declared as an object with external linkage in a header is
1316
  reserved to the implementation to designate that library object with
1317
+ external linkage, [^22] both in namespace `std` and in the global
1318
  namespace.
1319
 
1320
  Each global function signature declared with external linkage in a
1321
  header is reserved to the implementation to designate that function
1322
+ signature with external linkage.[^23]
1323
 
1324
+ Each name from the C standard library declared with external linkage is
1325
  reserved to the implementation for use as a name with `extern "C"`
1326
+ linkage, both in namespace `std` and in the global namespace.
1327
 
1328
+ Each function signature from the C standard library declared with
1329
  external linkage is reserved to the implementation for use as a function
1330
+ signature with both `extern "C"` and `extern "C++"` linkage,[^24] or as
1331
  a name of namespace scope in the global namespace.
1332
 
1333
  ##### Types <a id="extern.types">[[extern.types]]</a>
1334
 
1335
+ For each type T from the C standard library,[^25] the types `::T` and
1336
  `std::T` are reserved to the implementation and, when defined, `::T`
1337
  shall be identical to `std::T`.
1338
 
1339
  ##### User-defined literal suffixes <a id="usrlit.suffix">[[usrlit.suffix]]</a>
1340
 
1341
+ Literal suffix identifiers ([[over.literal]]) that do not start with an
1342
+ underscore are reserved for future standardization.
1343
 
1344
  #### Headers <a id="alt.headers">[[alt.headers]]</a>
1345
 
1346
  If a file with a name equivalent to the derived file name for one of the
1347
  C++standard library headers is not provided as part of the
 
1361
  describe the behavior of numerous functions defined by the C++standard
1362
  library. Under some circumstances, however, certain of these function
1363
  descriptions also apply to replacement functions defined in the
1364
  program ([[definitions]]).
1365
 
1366
+ A C++program may provide the definition for any of the following dynamic
1367
+ memory allocation function signatures declared in header `<new>` (
1368
  [[basic.stc.dynamic]], [[support.dynamic]]):
1369
 
1370
+ ``` cpp
1371
+ operator new(std::size_t)
1372
+ operator new(std::size_t, std::align_val_t)
1373
+ operator new(std::size_t, const std::nothrow_t&)
1374
+ operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
1375
+ ```
1376
+
1377
+ ``` cpp
1378
+ operator delete(void*)
1379
+ operator delete(void*, std::size_t)
1380
+ operator delete(void*, std::align_val_t)
1381
+ operator delete(void*, std::size_t, std::align_val_t)
1382
+ operator delete(void*, const std::nothrow_t&)
1383
+ operator delete(void*, std::align_val_t, const std::nothrow_t&)
1384
+ ```
1385
+
1386
+ ``` cpp
1387
+ operator new[](std::size_t)
1388
+ operator new[](std::size_t, std::align_val_t)
1389
+ operator new[](std::size_t, const std::nothrow_t&)
1390
+ operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
1391
+ ```
1392
+
1393
+ ``` cpp
1394
+ operator delete[](void*)
1395
+ operator delete[](void*, std::size_t)
1396
+ operator delete[](void*, std::align_val_t)
1397
+ operator delete[](void*, std::size_t, std::align_val_t)
1398
+ operator delete[](void*, const std::nothrow_t&)
1399
+ operator delete[](void*, std::align_val_t, const std::nothrow_t&)
1400
+ ```
1401
 
1402
  The program’s definitions are used instead of the default versions
1403
  supplied by the implementation ([[support.dynamic]]). Such replacement
1404
  occurs prior to program startup ([[basic.def.odr]], [[basic.start]]).
1405
+ The program’s declarations shall not be specified as `inline`. No
1406
  diagnostic is required.
1407
 
1408
  #### Handler functions <a id="handler.functions">[[handler.functions]]</a>
1409
 
1410
+ The C++standard library provides a default version of the following
1411
+ handler function (Clause  [[language.support]]):
1412
 
 
1413
  - `terminate_handler`
1414
 
1415
  A C++program may install different handler functions during execution,
1416
  by supplying a pointer to a function defined in the program or the
1417
  library as an argument to (respectively):
1418
 
1419
  - `set_new_handler`
1420
+ - `set_terminate`
1421
+
1422
+ See also subclauses  [[alloc.errors]], Storage allocation errors, and 
1423
+ [[support.exception]], Exception handling.
1424
 
1425
  A C++program can get a pointer to the current handler function by
1426
  calling the following functions:
1427
 
1428
  - `get_new_handler`
 
1429
  - `get_terminate`
1430
 
1431
  Calling the `set_*` and `get_*` functions shall not incur a data race. A
1432
  call to any of the `set_*` functions shall synchronize with subsequent
1433
  calls to the same `set_*` function and to the corresponding `get_*`
 
1436
  #### Other functions <a id="res.on.functions">[[res.on.functions]]</a>
1437
 
1438
  In certain cases (replacement functions, handler functions, operations
1439
  on types used to instantiate standard library template components), the
1440
  C++standard library depends on components supplied by a C++program. If
1441
+ these components do not meet their requirements, this International
1442
+ Standard places no requirements on the implementation.
1443
 
1444
  In particular, the effects are undefined in the following cases:
1445
 
1446
  - for replacement functions ([[new.delete]]), if the installed
1447
  replacement function does not implement the semantics of the
1448
  applicable *Required behavior:* paragraph.
1449
+ - for handler functions ([[new.handler]], [[terminate.handler]]), if
1450
+ the installed handler function does not implement the semantics of the
1451
+ applicable *Required behavior:* paragraph
 
1452
  - for types used as template arguments when instantiating a template
1453
  component, if the operations on the type do not implement the
1454
+ semantics of the applicable *Requirements* subclause (
1455
+ [[allocator.requirements]], [[container.requirements]],
1456
+ [[iterator.requirements]], [[algorithms.requirements]],
1457
  [[numeric.requirements]]). Operations on such types can report a
1458
  failure by throwing an exception unless otherwise specified.
1459
  - if any replacement function or handler function or destructor
1460
  operation exits via an exception, unless specifically allowed in the
1461
  applicable *Required behavior:* paragraph.
 
1476
  address computations and accesses to objects (that would be valid if
1477
  the pointer did point to the first element of such an array) are in
1478
  fact valid.
1479
  - If a function argument binds to an rvalue reference parameter, the
1480
  implementation may assume that this parameter is a unique reference to
1481
+ this argument. \[*Note 1*: If the parameter is a generic parameter of
1482
+ the form `T&&` and an lvalue of type `A` is bound, the argument binds
1483
+ to an lvalue reference ([[temp.deduct.call]]) and thus is not covered
1484
+ by the previous sentence. *end note*] \[*Note 2*: If a program
1485
+ casts an lvalue to an xvalue while passing that lvalue to a library
1486
+ function (e.g. by calling the function with the argument
1487
+ `std::move(x)`), the program is effectively asking that function to
1488
+ treat that lvalue as a temporary. The implementation is free to
1489
+ optimize away aliasing checks which might be needed if the argument
1490
+ was an lvalue. — *end note*]
1491
 
1492
+ #### Library object access <a id="res.on.objects">[[res.on.objects]]</a>
1493
 
1494
  The behavior of a program is undefined if calls to standard library
1495
  functions from different threads may introduce a data race. The
1496
  conditions under which this may occur are specified in 
1497
+ [[res.on.data.races]].
 
 
 
1498
 
1499
+ [*Note 1*: Modifying an object of a standard library type that is
1500
+ shared between threads risks undefined behavior unless objects of that
1501
+ type are explicitly specified as being sharable without data races or
1502
+ the user supplies a locking mechanism. *end note*]
1503
+
1504
+ If an object of a standard library type is accessed, and the beginning
1505
+ of the object’s lifetime ([[basic.life]]) does not happen before the
1506
+ access, or the access does not happen before the end of the object’s
1507
+ lifetime, the behavior is undefined unless otherwise specified.
1508
+
1509
+ [*Note 2*: This applies even to objects such as mutexes intended for
1510
+ thread synchronization. — *end note*]
1511
 
1512
  #### Requires paragraph <a id="res.on.required">[[res.on.required]]</a>
1513
 
1514
  Violation of the preconditions specified in a function’s *Requires:*
1515
  paragraph results in undefined behavior unless the function’s *Throws:*
 
1522
 
1523
  This section describes the constraints upon, and latitude of,
1524
  implementations of the C++standard library.
1525
 
1526
  An implementation’s use of headers is discussed in  [[res.on.headers]],
1527
+ its use of macros in  [[res.on.macro.definitions]], non-member functions
1528
+ in  [[global.functions]], member functions in  [[member.functions]],
1529
+ data race avoidance in  [[res.on.data.races]], access specifiers in 
1530
  [[protection.within.classes]], class derivation in  [[derivation]], and
1531
  exceptions in  [[res.on.exception.handling]].
1532
 
1533
  #### Headers <a id="res.on.headers">[[res.on.headers]]</a>
1534
 
 
1541
  Certain types and macros are defined in more than one header. Every such
1542
  entity shall be defined such that any header that defines it may be
1543
  included after any other header that also defines it (
1544
  [[basic.def.odr]]).
1545
 
1546
+ The C standard library headers ([[depr.c.headers]]) shall include only
1547
+ their corresponding C++standard library header, as described in 
1548
+ [[headers]].
1549
 
1550
  #### Restrictions on macro definitions <a id="res.on.macro.definitions">[[res.on.macro.definitions]]</a>
1551
 
1552
  The names and global function signatures described in  [[contents]] are
1553
  reserved to the implementation.
 
1555
  All object-like macros defined by the C standard library and described
1556
  in this Clause as expanding to integral constant expressions are also
1557
  suitable for use in `#if` preprocessing directives, unless explicitly
1558
  stated otherwise.
1559
 
1560
+ #### Non-member functions <a id="global.functions">[[global.functions]]</a>
1561
 
1562
+ It is unspecified whether any non-member functions in the C++standard
1563
+ library are defined as `inline` ([[dcl.inline]]).
1564
 
1565
+ A call to a non-member function signature described in Clauses 
1566
+ [[language.support]] through  [[thread]] and Annex  [[depr]] shall
1567
+ behave as if the implementation declared no additional non-member
1568
+ function signatures.[^26]
1569
 
1570
+ An implementation shall not declare a non-member function signature with
1571
+ additional default arguments.
1572
 
1573
+ Unless otherwise specified, calls made by functions in the standard
1574
+ library to non-operator, non-member functions do not use functions from
1575
+ another namespace which are found through *argument-dependent name
1576
+ lookup* ([[basic.lookup.argdep]]).
1577
+
1578
+ [*Note 1*:
1579
+
1580
+ The phrase “unless otherwise specified” applies to cases such as the
1581
+ swappable with requirements ([[swappable.requirements]]). The exception
1582
+ for overloaded operators allows argument-dependent lookup in cases like
1583
+ that of `ostream_iterator::operator=` ([[ostream.iterator.ops]]):
1584
 
1585
  *Effects:*
1586
 
1587
  ``` cpp
1588
  *out_stream << value;
1589
  if (delim != 0)
1590
  *out_stream << delim;
1591
  return *this;
1592
  ```
1593
 
1594
+ — *end note*]
1595
+
1596
  #### Member functions <a id="member.functions">[[member.functions]]</a>
1597
 
1598
  It is unspecified whether any member functions in the C++standard
1599
+ library are defined as `inline` ([[dcl.inline]]).
1600
 
1601
+ For a non-virtual member function described in the C++standard library,
1602
+ an implementation may declare a different set of member function
1603
+ signatures, provided that any call to the member function that would
1604
+ select an overload from the set of declarations described in this
1605
+ International Standard behaves as if that overload were selected.
1606
 
1607
+ [*Note 1*: For instance, an implementation may add parameters with
1608
+ default values, or replace a member function with default arguments with
1609
+ two or more member functions with equivalent behavior, or add additional
1610
+ signatures for a member function name. *end note*]
 
 
1611
 
1612
+ #### Constexpr functions and constructors <a id="constexpr.functions">[[constexpr.functions]]</a>
 
 
1613
 
1614
+ This International Standard explicitly requires that certain standard
1615
+ library functions are `constexpr` ([[dcl.constexpr]]). An
1616
+ implementation shall not declare any standard library function signature
1617
+ as `constexpr` except for those where it is explicitly required. Within
1618
+ any header that provides any non-defining declarations of constexpr
1619
+ functions or constructors an implementation shall provide corresponding
1620
+ definitions.
 
1621
 
1622
  #### Requirements for stable algorithms <a id="algorithm.stable">[[algorithm.stable]]</a>
1623
 
1624
  When the requirements for an algorithm state that it is “stable” without
1625
  further elaboration, it means:
 
1633
  original order) precede the elements from the second range (preserving
1634
  their original order).
1635
 
1636
  #### Reentrancy <a id="reentrancy">[[reentrancy]]</a>
1637
 
1638
+ Except where explicitly specified in this International Standard, it is
1639
+ *implementation-defined* which functions in the C++standard library may
1640
  be recursively reentered.
1641
 
1642
  #### Data race avoidance <a id="res.on.data.races">[[res.on.data.races]]</a>
1643
 
1644
  This section specifies requirements that implementations shall meet to
 
1655
  A C++standard library function shall not directly or indirectly modify
1656
  objects ([[intro.multithread]]) accessible by threads other than the
1657
  current thread unless the objects are accessed directly or indirectly
1658
  via the function’s non-const arguments, including `this`.
1659
 
1660
+ [*Note 1*: This means, for example, that implementations can’t use a
1661
+ static object for internal purposes without synchronization because it
1662
+ could cause a data race even in programs that do not explicitly share
1663
+ objects between threads. — *end note*]
1664
 
1665
  A C++standard library function shall not access objects indirectly
1666
  accessible via its arguments or via elements of its container arguments
1667
  except by invoking functions required by its specification on those
1668
  container elements.
1669
 
1670
  Operations on iterators obtained by calling a standard library container
1671
  or string member function may access the underlying container, but shall
1672
+ not modify it.
1673
+
1674
+ [*Note 2*: In particular, container operations that invalidate
1675
  iterators conflict with operations on iterators associated with that
1676
+ container. — *end note*]
1677
 
1678
  Implementations may share their own internal objects between threads if
1679
  the objects are not visible to users and are protected against data
1680
  races.
1681
 
1682
  Unless otherwise specified, C++standard library functions shall perform
1683
  all operations solely within the current thread if those operations have
1684
  effects that are visible ([[intro.multithread]]) to users.
1685
 
1686
+ [*Note 3*: This allows implementations to parallelize operations if
1687
+ there are no visible side effects. — *end note*]
1688
 
1689
  #### Protection within classes <a id="protection.within.classes">[[protection.within.classes]]</a>
1690
 
1691
  It is unspecified whether any function signature or class described in
1692
  Clauses  [[language.support]] through  [[thread]] and Annex  [[depr]] is
 
1704
  implementation.
1705
 
1706
  In any case:
1707
 
1708
  - Every base class described as `virtual` shall be virtual;
1709
+ - Every base class not specified as `virtual` shall not be virtual;
1710
  - Unless explicitly stated otherwise, types with distinct names shall be
1711
+ distinct types.[^27]
1712
+
1713
+ All types specified in the C++standard library shall be non-`final`
1714
+ types unless otherwise specified.
1715
 
1716
  #### Restrictions on exception handling <a id="res.on.exception.handling">[[res.on.exception.handling]]</a>
1717
 
1718
  Any of the functions defined in the C++standard library can report a
1719
+ failure by throwing an exception of a type described in its *Throws:*
1720
+ paragraph, or of a type derived from a type named in the *Throws:*
1721
+ paragraph that would be caught by an exception handler for the base
1722
+ type.
1723
 
1724
+ Functions from the C standard library shall not throw exceptions [^28]
 
 
 
 
1725
  except when such a function calls a program-supplied function that
1726
+ throws an exception.[^29]
1727
 
1728
  Destructor operations defined in the C++standard library shall not throw
1729
  exceptions. Every destructor in the C++standard library shall behave as
1730
+ if it had a non-throwing exception specification.
1731
+
1732
+ Functions defined in the C++standard library that do not have a
1733
+ *Throws:* paragraph but do have a potentially-throwing exception
1734
+ specification may throw *implementation-defined* exceptions. [^30]
1735
+ Implementations should report errors by throwing exceptions of or
1736
+ derived from the standard exception classes ([[bad.alloc]],
1737
+ [[support.exception]], [[std.exceptions]]).
1738
+
1739
+ An implementation may strengthen the exception specification for a
1740
+ non-virtual function by adding a non-throwing exception specification.
1741
 
1742
  #### Restrictions on storage of pointers <a id="res.on.pointer.storage">[[res.on.pointer.storage]]</a>
1743
 
1744
  Objects constructed by the standard library that may hold a
1745
  user-supplied pointer value or an integer of type `std::intptr_t` shall
1746
  store such values in a traceable pointer location (
1747
+ [[basic.stc.dynamic.safety]]).
1748
+
1749
+ [*Note 1*: Other libraries are strongly encouraged to do the same,
1750
+ since not doing so may result in accidental use of pointers that are not
1751
+ safely derived. Libraries that store pointers outside the user’s address
1752
+ space should make it appear that they are stored and retrieved from a
1753
+ traceable pointer location. — *end note*]
1754
 
1755
  #### Value of error codes <a id="value.error.codes">[[value.error.codes]]</a>
1756
 
1757
  Certain functions in the C++standard library report errors via a
1758
  `std::error_code` ([[syserr.errcode.overview]]) object. That object’s
1759
  `category()` member shall return `std::system_category()` for errors
1760
  originating from the operating system, or a reference to an
1761
  *implementation-defined* `error_category` object for errors originating
1762
  elsewhere. The implementation shall define the possible values of
1763
+ `value()` for each of these error categories.
1764
+
1765
+ [*Example 1*: For operating systems that are based on POSIX,
1766
+ implementations are encouraged to define the `std::system_category()`
1767
+ values as identical to the POSIX `errno` values, with additional values
1768
+ as defined by the operating system’s documentation. Implementations for
1769
+ operating systems that are not based on POSIX are encouraged to define
1770
+ values identical to the operating system’s values. For errors that do
1771
+ not originate from the operating system, the implementation may provide
1772
+ enums for the associated values. — *end example*]
1773
 
1774
  #### Moved-from state of library types <a id="lib.types.movedfrom">[[lib.types.movedfrom]]</a>
1775
 
1776
  Objects of types defined in the C++standard library may be moved from (
1777
  [[class.copy]]). Move operations may be explicitly specified or
 
1781
  <!-- Link reference definitions -->
1782
  [alg.c.library]: algorithms.md#alg.c.library
1783
  [alg.sorting]: algorithms.md#alg.sorting
1784
  [algorithm.stable]: #algorithm.stable
1785
  [algorithms]: algorithms.md#algorithms
1786
+ [algorithms.requirements]: algorithms.md#algorithms.requirements
1787
  [alloc.errors]: language.md#alloc.errors
1788
  [allocator.requirements]: #allocator.requirements
1789
+ [allocator.requirements.completeness]: #allocator.requirements.completeness
1790
  [allocator.traits]: utilities.md#allocator.traits
1791
  [alt.headers]: #alt.headers
1792
  [atomics]: atomics.md#atomics
1793
  [bad.alloc]: language.md#bad.alloc
1794
  [basic.def.odr]: basic.md#basic.def.odr
1795
  [basic.fundamental]: basic.md#basic.fundamental
1796
+ [basic.life]: basic.md#basic.life
1797
  [basic.link]: basic.md#basic.link
1798
  [basic.lookup.argdep]: basic.md#basic.lookup.argdep
1799
  [basic.scope.namespace]: basic.md#basic.scope.namespace
1800
  [basic.start]: basic.md#basic.start
1801
  [basic.stc.dynamic]: basic.md#basic.stc.dynamic
 
1804
  [bitmask.types]: #bitmask.types
1805
  [byte.strings]: #byte.strings
1806
  [c.locales]: localization.md#c.locales
1807
  [c.strings]: strings.md#c.strings
1808
  [character.seq]: #character.seq
1809
+ [class.conv.ctor]: special.md#class.conv.ctor
1810
  [class.copy]: special.md#class.copy
1811
  [class.ctor]: special.md#class.ctor
1812
  [class.dtor]: special.md#class.dtor
1813
  [class.mem]: class.md#class.mem
1814
  [class.mfct]: class.md#class.mfct
 
1829
  [cstdint]: language.md#cstdint
1830
  [dcl.array]: dcl.md#dcl.array
1831
  [dcl.attr]: dcl.md#dcl.attr
1832
  [dcl.constexpr]: dcl.md#dcl.constexpr
1833
  [dcl.fct.default]: dcl.md#dcl.fct.default
 
1834
  [dcl.init]: dcl.md#dcl.init
1835
+ [dcl.init.list]: dcl.md#dcl.init.list
1836
+ [dcl.inline]: dcl.md#dcl.inline
1837
  [dcl.link]: dcl.md#dcl.link
1838
  [definitions]: #definitions
 
1839
  [depr]: future.md#depr
1840
  [depr.c.headers]: future.md#depr.c.headers
1841
+ [depr.cstdalign.syn]: future.md#depr.cstdalign.syn
1842
+ [depr.cstdbool.syn]: future.md#depr.cstdbool.syn
1843
  [derivation]: #derivation
1844
  [derived.classes]: #derived.classes
1845
  [description]: #description
 
1846
  [diagnostics]: diagnostics.md#diagnostics
1847
  [enumerated.types]: #enumerated.types
 
1848
  [except]: except.md#except
1849
+ [expos.only.types]: #expos.only.types
1850
+ [expr.cond]: expr.md#expr.cond
1851
+ [expr.const]: expr.md#expr.const
1852
  [expr.delete]: expr.md#expr.delete
1853
  [expr.eq]: expr.md#expr.eq
1854
  [expr.new]: expr.md#expr.new
1855
  [expr.rel]: expr.md#expr.rel
1856
  [extern.names]: #extern.names
1857
  [extern.types]: #extern.types
1858
  [function.objects]: utilities.md#function.objects
1859
  [functions.within.classes]: #functions.within.classes
1860
  [global.functions]: #global.functions
 
1861
  [handler.functions]: #handler.functions
 
1862
  [hash.requirements]: #hash.requirements
1863
  [headers]: #headers
1864
  [input.output]: input.md#input.output
1865
  [intro.compliance]: intro.md#intro.compliance
1866
  [intro.defs]: intro.md#intro.defs
1867
  [intro.multithread]: intro.md#intro.multithread
1868
  [intro.refs]: intro.md#intro.refs
1869
  [iterator.requirements]: iterators.md#iterator.requirements
1870
+ [iterator.requirements.general]: iterators.md#iterator.requirements.general
1871
  [iterators]: iterators.md#iterators
1872
  [language.support]: language.md#language.support
1873
  [lex]: lex.md#lex
 
1874
  [lex.phases]: lex.md#lex.phases
1875
  [lib.types.movedfrom]: #lib.types.movedfrom
1876
  [library]: #library
1877
  [library.c]: #library.c
1878
  [library.general]: #library.general
 
1882
  [member.functions]: #member.functions
1883
  [meta]: utilities.md#meta
1884
  [multibyte.strings]: #multibyte.strings
1885
  [namespace.constraints]: #namespace.constraints
1886
  [namespace.def]: dcl.md#namespace.def
1887
+ [namespace.future]: #namespace.future
1888
  [namespace.posix]: #namespace.posix
1889
  [namespace.std]: #namespace.std
1890
  [namespace.udecl]: dcl.md#namespace.udecl
1891
  [new.delete]: language.md#new.delete
1892
  [new.handler]: language.md#new.handler
 
1893
  [nullablepointer.requirements]: #nullablepointer.requirements
1894
  [numeric.requirements]: numerics.md#numeric.requirements
1895
  [numerics]: numerics.md#numerics
1896
  [objects.within.classes]: #objects.within.classes
1897
  [organization]: #organization
1898
  [ostream.iterator.ops]: iterators.md#ostream.iterator.ops
1899
+ [over.literal]: over.md#over.literal
1900
  [over.match]: over.md#over.match
1901
  [over.oper]: over.md#over.oper
1902
  [protection.within.classes]: #protection.within.classes
1903
+ [random.access.iterators]: iterators.md#random.access.iterators
1904
  [re]: re.md#re
1905
  [reentrancy]: #reentrancy
1906
  [replacement.functions]: #replacement.functions
1907
  [requirements]: #requirements
1908
  [res.on.arguments]: #res.on.arguments
 
1933
  [support.start.term]: language.md#support.start.term
1934
  [support.types]: language.md#support.types
1935
  [swappable.requirements]: #swappable.requirements
1936
  [syserr]: diagnostics.md#syserr
1937
  [syserr.errcode.overview]: diagnostics.md#syserr.errcode.overview
1938
+ [tab:c.annex.k.names]: #tab:c.annex.k.names
1939
+ [tab:copyassignable]: #tab:copyassignable
1940
  [tab:cpp.c.headers]: #tab:cpp.c.headers
1941
  [tab:cpp.headers.freestanding]: #tab:cpp.headers.freestanding
1942
  [tab:cpp.library.headers]: #tab:cpp.library.headers
1943
  [tab:desc.var.def]: #tab:desc.var.def
1944
+ [tab:destructible]: #tab:destructible
1945
+ [tab:equalitycomparable]: #tab:equalitycomparable
1946
+ [tab:hash]: #tab:hash
1947
  [tab:identifiers.special]: lex.md#tab:identifiers.special
1948
  [tab:library.categories]: #tab:library.categories
1949
+ [tab:moveassignable]: #tab:moveassignable
1950
+ [tab:nullablepointer]: #tab:nullablepointer
1951
  [tab:utilities.allocator.requirements]: #tab:utilities.allocator.requirements
1952
  [temp.deduct.call]: temp.md#temp.deduct.call
1953
  [template.bitset]: utilities.md#template.bitset
1954
  [terminate.handler]: language.md#terminate.handler
1955
  [thread]: thread.md#thread
1956
  [type.descriptions]: #type.descriptions
1957
  [type.descriptions.general]: #type.descriptions.general
 
1958
  [using]: #using
1959
  [using.headers]: #using.headers
1960
  [using.linkage]: #using.linkage
1961
  [using.overview]: #using.overview
1962
  [usrlit.suffix]: #usrlit.suffix
1963
  [utilities]: utilities.md#utilities
1964
  [utility]: utilities.md#utility
1965
  [utility.arg.requirements]: #utility.arg.requirements
1966
  [utility.requirements]: #utility.requirements
1967
  [value.error.codes]: #value.error.codes
1968
+ [zombie.names]: #zombie.names
1969
 
1970
+ [^1]: To save space, items that do not apply to a Clause are omitted.
 
 
1971
  For example, if a Clause does not specify any requirements, there
1972
  will be no “Requirements” subclause.
1973
 
1974
+ [^2]: Although in some cases the code given is unambiguously the optimum
1975
  implementation.
1976
 
1977
+ [^3]: To save space, items that do not apply to a class are omitted. For
1978
  example, if a class does not specify any comparison functions, there
1979
  will be no “Comparison functions” subclause.
1980
 
1981
+ [^4]: To save space, items that do not apply to a function are omitted.
1982
  For example, if a function does not specify any further
1983
+ preconditions, there will be no *Requires:* paragraph.
1984
 
1985
+ [^5]: This simplifies the presentation of complexity requirements in
1986
  some cases.
1987
 
1988
+ [^6]: Examples from  [[utility.requirements]] include:
1989
  `EqualityComparable`, `LessThanComparable`, `CopyConstructible`.
1990
  Examples from  [[iterator.requirements]] include: `InputIterator`,
1991
+ `ForwardIterator`.
1992
 
1993
+ [^7]: Such as an integer type, with constant integer values (
1994
  [[basic.fundamental]]).
1995
 
1996
+ [^8]: declared in `<clocale>` ([[c.locales]]).
 
1997
 
1998
+ [^9]: Many of the objects manipulated by function signatures declared in
1999
+ `<cstring>` ([[c.strings]]) are character sequences or NTBSs. The
2000
+ size of some of these character sequences is limited by a length
 
 
2001
  value, maintained separately from the character sequence.
2002
 
2003
+ [^10]: A string literal, such as `"abc"`, is a static NTBS.
2004
 
2005
+ [^11]: An NTBSthat contains characters only from the basic execution
2006
  character set is also an NTMBS. Each multibyte character then
2007
  consists of a single byte.
2008
 
2009
+ [^12]: The C standard library headers (Annex  [[depr.c.headers]]) also
2010
  define names within the global namespace, while the C++headers for C
2011
  library facilities ([[headers]]) may also define names within the
2012
  global namespace.
2013
 
2014
+ [^13]: This gives implementers freedom to use inline namespaces to
2015
  support multiple configurations of the library.
2016
 
2017
+ [^14]: A header is not necessarily a source file, nor are the sequences
2018
  delimited by `<` and `>` in header names necessarily valid source
2019
  file names ([[cpp.include]]).
2020
 
2021
+ [^15]: It is intentional that there is no C++header for any of these C
2022
+ headers: `<stdatomic.h>`, `<stdnoreturn.h>`, `<threads.h>`.
2023
+
2024
+ [^16]: This disallows the practice, allowed in C, of providing a masking
2025
  macro in addition to the function prototype. The only way to achieve
2026
  equivalent inline behavior in C++is to provide a definition as an
2027
  extern inline function.
2028
 
2029
+ [^17]: In particular, including the standard header `<iso646.h>` or
2030
  `<ciso646>` has no effect.
2031
 
2032
+ [^18]: The `".h"` headers dump all their names into the global
2033
  namespace, whereas the newer forms keep their names in namespace
2034
  `std`. Therefore, the newer forms are the preferred forms for all
2035
  uses except for C++programs which are intended to be strictly
2036
  compatible with C.
2037
 
2038
+ [^19]: This is the same as the C standard library.
2039
 
2040
+ [^20]: The only reliable way to declare an object or function signature
2041
+ from the C standard library is by including the header that declares
2042
  it, notwithstanding the latitude granted in 7.1.4 of the C Standard.
2043
 
2044
+ [^21]: Any library code that instantiates other library templates must
2045
  be prepared to work adequately with any user-supplied specialization
2046
+ that meets the minimum requirements of this International Standard.
2047
 
2048
+ [^22]: The list of such reserved names includes `errno`, declared or
2049
  defined in `<cerrno>`.
2050
 
2051
+ [^23]: The list of such reserved function signatures with external
2052
  linkage includes `setjmp(jmp_buf)`, declared or defined in
2053
  `<csetjmp>`, and `va_end(va_list)`, declared or defined in
2054
  `<cstdarg>`.
2055
 
2056
+ [^24]: The function signatures declared in `<cuchar>`, `<cwchar>`, and
2057
  `<cwctype>` are always reserved, notwithstanding the restrictions
2058
  imposed in subclause 4.5.1 of Amendment 1 to the C Standard for
2059
  these headers.
2060
 
2061
+ [^25]: These types are `clock_t`, `div_t`, `FILE`, `fpos_t`, `lconv`,
2062
  `ldiv_t`, `mbstate_t`, `ptrdiff_t`, `sig_atomic_t`, `size_t`,
2063
  `time_t`, `tm`, `va_list`, `wctrans_t`, `wctype_t`, and `wint_t`.
2064
 
2065
+ [^26]: A valid C++program always calls the expected library non-member
2066
+ function. An implementation may also define additional non-member
2067
+ functions that would otherwise not be called by a valid C++program.
 
2068
 
2069
+ [^27]: There is an implicit exception to this rule for types that are
 
 
 
 
 
 
 
 
2070
  described as synonyms for basic integral types, such as `size_t` (
2071
  [[support.types]]) and `streamoff` ([[stream.types]]).
2072
 
2073
+ [^28]: That is, the C library functions can all be treated as if they
2074
  are marked `noexcept`. This allows implementations to make
2075
  performance optimizations based on the absence of exceptions at
2076
  runtime.
2077
 
2078
+ [^29]: The functions `qsort()` and `bsearch()` ([[alg.c.library]]) meet
2079
  this condition.
2080
 
2081
+ [^30]: In particular, they can report a failure to allocate storage by
2082
  throwing an exception of type `bad_alloc`, or a class derived from
2083
+ `bad_alloc` ([[bad.alloc]]).