From Jason Turner

[requirements]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp4t3boq8t/{from.md → to.md} +82 -27
tmp/tmp4t3boq8t/{from.md → to.md} RENAMED
@@ -42,11 +42,11 @@ function `::std::G` is meant.
42
  #### Headers <a id="headers">[[headers]]</a>
43
 
44
  Each element of the C++standard library is declared or defined (as
45
  appropriate) in a *header*.[^16]
46
 
47
- The C++standard library provides 52 *C++library headers*, as shown in
48
  Table  [[tab:cpp.library.headers]].
49
 
50
  **Table: C++library headers** <a id="tab:cpp.library.headers">[tab:cpp.library.headers]</a>
51
 
52
  | | | | | |
@@ -159,11 +159,11 @@ either `<cassert>` or `<assert.h>` depends each time on the lexically
159
  current definition of `NDEBUG`.[^20]
160
 
161
  A translation unit shall include a header only outside of any external
162
  declaration or definition, and shall include the header lexically before
163
  the first reference in that translation unit to any of the entities
164
- declared in that header.
165
 
166
  #### Linkage <a id="using.linkage">[[using.linkage]]</a>
167
 
168
  Entities in the C++standard library have external linkage (
169
  [[basic.link]]). Unless otherwise specified, objects and functions have
@@ -259,15 +259,15 @@ signatures is called using the default argument ([[dcl.fct.default]]).
259
 
260
 
261
  **Table: `Destructible` requirements** <a id="destructible">[destructible]</a>
262
 
263
  | | |
264
- | ------------- | --------------------------------------------------------------------- |
265
- | `u.$\sim$T()` | All resources owned by `u` are reclaimed, no exception is propagated. |
266
 
267
 
268
- #### Swappable requirements <a id="swappable.requirements">[[swappable.requirements]]</a>
269
 
270
  This subclause provides definitions for swappable types and expressions.
271
  In these definitions, let `t` denote an expression of type `T`, and let
272
  `u` denote an expression of type `U`.
273
 
@@ -301,12 +301,13 @@ evaluation context.
301
 
302
  An rvalue or lvalue `t` is *swappable* if and only if `t` is swappable
303
  with any rvalue or lvalue, respectively, of type `T`.
304
 
305
  A type `X` satisfying any of the iterator requirements (
306
- [[iterator.requirements]]) is *ValueSwappable* if, for any
307
- dereferenceable object `x` of type `X`, `*x` is swappable.
 
308
 
309
  User code can ensure that the evaluation of `swap` calls is performed in
310
  an appropriate context under the various conditions as follows:
311
 
312
  ``` cpp
@@ -411,12 +412,12 @@ lvalue of type `Key`, and `k` is a value of a type convertible to
411
  (possibly `const`) `Key`.
412
 
413
  **Table: `Hash` requirements** <a id="hash">[hash]</a>
414
 
415
  | | | |
416
- | ------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
417
- | `h(k)` | `size_t` | The value returned shall depend only on the argument `k`. \enternote Thus all evaluations of the expression `h(k)` with the same value for `k` yield the same result. \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 |
418
  | `h(u)` | `size_t` | Shall not modify `u`. |
419
 
420
 
421
  #### Allocator requirements <a id="allocator.requirements">[[allocator.requirements]]</a>
422
 
@@ -456,17 +457,54 @@ class template instantiation of the form `SomeAllocator<T, Args>`, where
456
  `rebind` member template, the standard `allocator_traits` template uses
457
  `SomeAllocator<U, Args>` in place of `Allocator::{}rebind<U>::other` by
458
  default. For allocator types that are not template instantiations of the
459
  above form, no default is provided.
460
 
461
- The `X::pointer`, `X::const_pointer`, `X::void_pointer`, and
462
- `X::const_void_pointer` types shall satisfy the requirements of
463
- `NullablePointer` ([[nullablepointer.requirements]]). No constructor,
464
- comparison operator, copy operation, move operation, or swap operation
465
- on these types shall exit via an exception. `X::pointer` and
466
- `X::const_pointer` shall also satisfy the requirements for a random
467
- access iterator ([[iterator.requirements]]).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
468
 
469
  An allocator may constrain the types on which it can be instantiated and
470
  the arguments for which its `construct` member may be called. If a type
471
  cannot be used with a particular allocator, the allocator class or the
472
  call to `construct` may fail to instantiate.
@@ -484,10 +522,15 @@ struct SimpleAllocator {
484
  template <class T> SimpleAllocator(const SimpleAllocator<T>& other);
485
 
486
  Tp* allocate(std::size_t n);
487
  void deallocate(Tp* p, std::size_t n);
488
  };
 
 
 
 
 
489
  ```
490
 
491
  If the alignment associated with a specific over-aligned type is not
492
  supported by an allocator, instantiation of the allocator for that type
493
  may fail. The allocator also may silently ignore the requested
@@ -627,11 +670,11 @@ Clauses  [[language.support]] through  [[thread]] and Annex  [[depr]]
627
  describe the behavior of numerous functions defined by the C++standard
628
  library. Under some circumstances, however, certain of these function
629
  descriptions also apply to replacement functions defined in the
630
  program ([[definitions]]).
631
 
632
- A C++program may provide the definition for any of eight dynamic memory
633
  allocation function signatures declared in header `<new>` (
634
  [[basic.stc.dynamic]], [[support.dynamic]]):
635
 
636
  - `operator new(std::size_t)`
637
  - `operator new(std::size_t, const std::nothrow_t&)`
@@ -639,10 +682,14 @@ allocation function signatures declared in header `<new>` (
639
  - `operator new[](std::size_t, const std::nothrow_t&)`
640
  - `operator delete(void*)`
641
  - `operator delete(void*, const std::nothrow_t&)`
642
  - `operator delete[](void*)`
643
  - `operator delete[](void*, const std::nothrow_t&)`
 
 
 
 
644
 
645
  The program’s definitions are used instead of the default versions
646
  supplied by the implementation ([[support.dynamic]]). Such replacement
647
  occurs prior to program startup ([[basic.def.odr]], [[basic.start]]).
648
  The program’s definitions shall not be specified as `inline`. No
@@ -813,17 +860,19 @@ signature with additional default arguments.
813
  Unless otherwise specified, global and non-member functions in the
814
  standard library shall not use functions from another namespace which
815
  are found through *argument-dependent name lookup* (
816
  [[basic.lookup.argdep]]). The phrase “unless otherwise specified” is
817
  intended to allow argument-dependent lookup in cases like that of
818
- `ostream_iterator`s: *Effects:*
 
 
819
 
820
  ``` cpp
821
  *out_stream << value;
822
  if (delim != 0)
823
  *out_stream << delim;
824
- return (*this);
825
  ```
826
 
827
  #### Member functions <a id="member.functions">[[member.functions]]</a>
828
 
829
  It is unspecified whether any member functions in the C++standard
@@ -843,26 +892,30 @@ A call to a member function signature described in the C++standard
843
  library behaves as if the implementation declares no additional member
844
  function signatures.[^29]
845
 
846
  #### `constexpr` functions and constructors <a id="constexpr.functions">[[constexpr.functions]]</a>
847
 
848
- Within any header that provides any non-defining declarations of
849
- `constexpr` functions or constructors an implementation shall provide
850
- corresponding definitions.
 
 
 
851
 
852
  #### Requirements for stable algorithms <a id="algorithm.stable">[[algorithm.stable]]</a>
853
 
854
  When the requirements for an algorithm state that it is “stable” without
855
  further elaboration, it means:
856
 
857
  - For the *sort* algorithms the relative order of equivalent elements is
858
  preserved.
859
- - For the *remove* algorithms the relative order of the elements that
860
- are not removed is preserved.
861
  - For the *merge* algorithms, for equivalent elements in the original
862
- two ranges, the elements from the first range precede the elements
863
- from the second range.
 
864
 
865
  #### Reentrancy <a id="reentrancy">[[reentrancy]]</a>
866
 
867
  Except where explicitly specified in this standard, it is
868
  *implementation-defined* which functions in the Standard C++ library may
@@ -1040,10 +1093,11 @@ objects shall be placed in a valid but unspecified state.
1040
  [conventions]: #conventions
1041
  [cpp.include]: cpp.md#cpp.include
1042
  [cstdint]: language.md#cstdint
1043
  [dcl.array]: dcl.md#dcl.array
1044
  [dcl.attr]: dcl.md#dcl.attr
 
1045
  [dcl.fct.default]: dcl.md#dcl.fct.default
1046
  [dcl.fct.spec]: dcl.md#dcl.fct.spec
1047
  [dcl.init]: dcl.md#dcl.init
1048
  [dcl.link]: dcl.md#dcl.link
1049
  [definitions]: #definitions
@@ -1104,10 +1158,11 @@ objects shall be placed in a valid but unspecified state.
1104
  [nullablepointer.requirements]: #nullablepointer.requirements
1105
  [numeric.requirements]: numerics.md#numeric.requirements
1106
  [numerics]: numerics.md#numerics
1107
  [objects.within.classes]: #objects.within.classes
1108
  [organization]: #organization
 
1109
  [over.match]: over.md#over.match
1110
  [over.oper]: over.md#over.oper
1111
  [protection.within.classes]: #protection.within.classes
1112
  [re]: re.md#re
1113
  [reentrancy]: #reentrancy
@@ -1240,11 +1295,11 @@ objects shall be placed in a valid but unspecified state.
1240
 
1241
  [^20]: This is the same as the Standard C library.
1242
 
1243
  [^21]: The only reliable way to declare an object or function signature
1244
  from the Standard C library is by including the header that declares
1245
- it, notwithstanding the latitude granted in 7.1.7 of the C Standard.
1246
 
1247
  [^22]: Any library code that instantiates other library templates must
1248
  be prepared to work adequately with any user-supplied specialization
1249
  that meets the minimum requirements of the Standard.
1250
 
 
42
  #### Headers <a id="headers">[[headers]]</a>
43
 
44
  Each element of the C++standard library is declared or defined (as
45
  appropriate) in a *header*.[^16]
46
 
47
+ The C++standard library provides 53 *C++library headers*, as shown in
48
  Table  [[tab:cpp.library.headers]].
49
 
50
  **Table: C++library headers** <a id="tab:cpp.library.headers">[tab:cpp.library.headers]</a>
51
 
52
  | | | | | |
 
159
  current definition of `NDEBUG`.[^20]
160
 
161
  A translation unit shall include a header only outside of any external
162
  declaration or definition, and shall include the header lexically before
163
  the first reference in that translation unit to any of the entities
164
+ declared in that header. No diagnostic is required.
165
 
166
  #### Linkage <a id="using.linkage">[[using.linkage]]</a>
167
 
168
  Entities in the C++standard library have external linkage (
169
  [[basic.link]]). Unless otherwise specified, objects and functions have
 
259
 
260
 
261
  **Table: `Destructible` requirements** <a id="destructible">[destructible]</a>
262
 
263
  | | |
264
+ | -------- | --------------------------------------------------------------------- |
265
+ | `u.~T()` | All resources owned by `u` are reclaimed, no exception is propagated. |
266
 
267
 
268
+ #### `Swappable` requirements <a id="swappable.requirements">[[swappable.requirements]]</a>
269
 
270
  This subclause provides definitions for swappable types and expressions.
271
  In these definitions, let `t` denote an expression of type `T`, and let
272
  `u` denote an expression of type `U`.
273
 
 
301
 
302
  An rvalue or lvalue `t` is *swappable* if and only if `t` is swappable
303
  with any rvalue or lvalue, respectively, of type `T`.
304
 
305
  A type `X` satisfying any of the iterator requirements (
306
+ [[iterator.requirements]]) satisfies the requirements of
307
+ `ValueSwappable` if, for any dereferenceable object `x` of type `X`,
308
+ `*x` is swappable.
309
 
310
  User code can ensure that the evaluation of `swap` calls is performed in
311
  an appropriate context under the various conditions as follows:
312
 
313
  ``` cpp
 
412
  (possibly `const`) `Key`.
413
 
414
  **Table: `Hash` requirements** <a id="hash">[hash]</a>
415
 
416
  | | | |
417
+ | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
418
+ | `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 |
419
  | `h(u)` | `size_t` | Shall not modify `u`. |
420
 
421
 
422
  #### Allocator requirements <a id="allocator.requirements">[[allocator.requirements]]</a>
423
 
 
457
  `rebind` member template, the standard `allocator_traits` template uses
458
  `SomeAllocator<U, Args>` in place of `Allocator::{}rebind<U>::other` by
459
  default. For allocator types that are not template instantiations of the
460
  above form, no default is provided.
461
 
462
+ An allocator type `X` shall satisfy the requirements of
463
+ `CopyConstructible` ([[utility.arg.requirements]]). The `X::pointer`,
464
+ `X::const_pointer`, `X::void_pointer`, and `X::const_void_pointer` types
465
+ shall satisfy the requirements of `NullablePointer` (
466
+ [[nullablepointer.requirements]]). No constructor, comparison operator,
467
+ copy operation, move operation, or swap operation on these types shall
468
+ exit via an exception. `X::pointer` and `X::const_pointer` shall also
469
+ satisfy the requirements for a random access iterator (
470
+ [[iterator.requirements]]).
471
+
472
+ Let `x1` and `x2` denote objects of (possibly different) types
473
+ `X::void_pointer`, `X::const_void_pointer`, `X::pointer`, or
474
+ `X::const_pointer`. Then, `x1` and `x2` are *equivalently-valued*
475
+ pointer values, if and only if both `x1` and `x2` can be explicitly
476
+ converted to the two corresponding objects `px1` and `px2` of type
477
+ `X::const_pointer`, using a sequence of `static_cast`s using only these
478
+ four types, and the expression `px1 == px2` evaluates to `true`.
479
+
480
+ Let `w1` and `w2` denote objects of type `X::void_pointer`. Then for the
481
+ expressions
482
+
483
+ ``` cpp
484
+ w1 == w2
485
+ w1 != w2
486
+ ```
487
+
488
+ either or both objects may be replaced by an equivalently-valued object
489
+ of type `X::const_void_pointer` with no change in semantics.
490
+
491
+ Let `p1` and `p2` denote objects of type `X::pointer`. Then for the
492
+ expressions
493
+
494
+ ``` cpp
495
+ p1 == p2
496
+ p1 != p2
497
+ p1 < p2
498
+ p1 <= p2
499
+ p1 >= p2
500
+ p1 > p2
501
+ p1 - p2
502
+ ```
503
+
504
+ either or both objects may be replaced by an equivalently-valued object
505
+ of type `X::const_pointer` with no change in semantics.
506
 
507
  An allocator may constrain the types on which it can be instantiated and
508
  the arguments for which its `construct` member may be called. If a type
509
  cannot be used with a particular allocator, the allocator class or the
510
  call to `construct` may fail to instantiate.
 
522
  template <class T> SimpleAllocator(const SimpleAllocator<T>& other);
523
 
524
  Tp* allocate(std::size_t n);
525
  void deallocate(Tp* p, std::size_t n);
526
  };
527
+
528
+ template <class T, class U>
529
+ bool operator==(const SimpleAllocator<T>&, const SimpleAllocator<U>&);
530
+ template <class T, class U>
531
+ bool operator!=(const SimpleAllocator<T>&, const SimpleAllocator<U>&);
532
  ```
533
 
534
  If the alignment associated with a specific over-aligned type is not
535
  supported by an allocator, instantiation of the allocator for that type
536
  may fail. The allocator also may silently ignore the requested
 
670
  describe the behavior of numerous functions defined by the C++standard
671
  library. Under some circumstances, however, certain of these function
672
  descriptions also apply to replacement functions defined in the
673
  program ([[definitions]]).
674
 
675
+ A C++program may provide the definition for any of twelve dynamic memory
676
  allocation function signatures declared in header `<new>` (
677
  [[basic.stc.dynamic]], [[support.dynamic]]):
678
 
679
  - `operator new(std::size_t)`
680
  - `operator new(std::size_t, const std::nothrow_t&)`
 
682
  - `operator new[](std::size_t, const std::nothrow_t&)`
683
  - `operator delete(void*)`
684
  - `operator delete(void*, const std::nothrow_t&)`
685
  - `operator delete[](void*)`
686
  - `operator delete[](void*, const std::nothrow_t&)`
687
+ - `operator delete(void*, std::size_t)`
688
+ - `operator delete(void*, std::size_t, const std::nothrow_t&)`
689
+ - `operator delete[](void*, std::size_t)`
690
+ - `operator delete[](void*, std::size_t, const std::nothrow_t&)`
691
 
692
  The program’s definitions are used instead of the default versions
693
  supplied by the implementation ([[support.dynamic]]). Such replacement
694
  occurs prior to program startup ([[basic.def.odr]], [[basic.start]]).
695
  The program’s definitions shall not be specified as `inline`. No
 
860
  Unless otherwise specified, global and non-member functions in the
861
  standard library shall not use functions from another namespace which
862
  are found through *argument-dependent name lookup* (
863
  [[basic.lookup.argdep]]). The phrase “unless otherwise specified” is
864
  intended to allow argument-dependent lookup in cases like that of
865
+ `ostream_iterator::operator=` ([[ostream.iterator.ops]]):
866
+
867
+ *Effects:*
868
 
869
  ``` cpp
870
  *out_stream << value;
871
  if (delim != 0)
872
  *out_stream << delim;
873
+ return *this;
874
  ```
875
 
876
  #### Member functions <a id="member.functions">[[member.functions]]</a>
877
 
878
  It is unspecified whether any member functions in the C++standard
 
892
  library behaves as if the implementation declares no additional member
893
  function signatures.[^29]
894
 
895
  #### `constexpr` functions and constructors <a id="constexpr.functions">[[constexpr.functions]]</a>
896
 
897
+ This standard explicitly requires that certain standard library
898
+ functions are `constexpr` ([[dcl.constexpr]]). An implementation shall
899
+ not declare any standard library function signature as `constexpr`
900
+ except for those where it is explicitly required. Within any header that
901
+ provides any non-defining declarations of `constexpr` functions or
902
+ constructors an implementation shall provide corresponding definitions.
903
 
904
  #### Requirements for stable algorithms <a id="algorithm.stable">[[algorithm.stable]]</a>
905
 
906
  When the requirements for an algorithm state that it is “stable” without
907
  further elaboration, it means:
908
 
909
  - For the *sort* algorithms the relative order of equivalent elements is
910
  preserved.
911
+ - For the *remove* and *copy* algorithms the relative order of the
912
+ elements that are not removed is preserved.
913
  - For the *merge* algorithms, for equivalent elements in the original
914
+ two ranges, the elements from the first range (preserving their
915
+ original order) precede the elements from the second range (preserving
916
+ their original order).
917
 
918
  #### Reentrancy <a id="reentrancy">[[reentrancy]]</a>
919
 
920
  Except where explicitly specified in this standard, it is
921
  *implementation-defined* which functions in the Standard C++ library may
 
1093
  [conventions]: #conventions
1094
  [cpp.include]: cpp.md#cpp.include
1095
  [cstdint]: language.md#cstdint
1096
  [dcl.array]: dcl.md#dcl.array
1097
  [dcl.attr]: dcl.md#dcl.attr
1098
+ [dcl.constexpr]: dcl.md#dcl.constexpr
1099
  [dcl.fct.default]: dcl.md#dcl.fct.default
1100
  [dcl.fct.spec]: dcl.md#dcl.fct.spec
1101
  [dcl.init]: dcl.md#dcl.init
1102
  [dcl.link]: dcl.md#dcl.link
1103
  [definitions]: #definitions
 
1158
  [nullablepointer.requirements]: #nullablepointer.requirements
1159
  [numeric.requirements]: numerics.md#numeric.requirements
1160
  [numerics]: numerics.md#numerics
1161
  [objects.within.classes]: #objects.within.classes
1162
  [organization]: #organization
1163
+ [ostream.iterator.ops]: iterators.md#ostream.iterator.ops
1164
  [over.match]: over.md#over.match
1165
  [over.oper]: over.md#over.oper
1166
  [protection.within.classes]: #protection.within.classes
1167
  [re]: re.md#re
1168
  [reentrancy]: #reentrancy
 
1295
 
1296
  [^20]: This is the same as the Standard C library.
1297
 
1298
  [^21]: The only reliable way to declare an object or function signature
1299
  from the Standard C library is by including the header that declares
1300
+ it, notwithstanding the latitude granted in 7.1.4 of the C Standard.
1301
 
1302
  [^22]: Any library code that instantiates other library templates must
1303
  be prepared to work adequately with any user-supplied specialization
1304
  that meets the minimum requirements of the Standard.
1305