From Jason Turner

[utility.requirements]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmptaonxtw9/{from.md → to.md} +36 -16
tmp/tmptaonxtw9/{from.md → to.md} RENAMED
@@ -90,21 +90,21 @@ signatures is called using the default argument [[dcl.fct.default]].
90
 
91
  **Table: Cpp17Destructible requirements** <a id="cpp17.destructible">[cpp17.destructible]</a>
92
 
93
  | Expression | Post-condition |
94
  | ---------- | --------------------------------------------------------------------- |
95
- | `u.~T()` | All resources owned by `u` are reclaimed, no exception is propagated. |
96
  | *[spans 2 columns]* *Array types and non-object types are not Cpp17Destructible.* |
97
 
98
 
99
  #### Swappable requirements <a id="swappable.requirements">[[swappable.requirements]]</a>
100
 
101
  This subclause provides definitions for swappable types and expressions.
102
  In these definitions, let `t` denote an expression of type `T`, and let
103
  `u` denote an expression of type `U`.
104
 
105
- An object `t` is *swappable with* an object `u` if and only if:
106
 
107
  - the expressions `swap(t, u)` and `swap(u, t)` are valid when evaluated
108
  in the context described below, and
109
  - these expressions have the following effects:
110
  - the object referred to by `t` has the value originally held by `u`
@@ -130,16 +130,15 @@ swappable requirement includes the header `<utility>` to ensure an
130
  appropriate evaluation context. — *end note*]
131
 
132
  An rvalue or lvalue `t` is *swappable* if and only if `t` is swappable
133
  with any rvalue or lvalue, respectively, of type `T`.
134
 
135
- A type `X` meets the *Cpp17Swappable* requirements if lvalues of type
136
- `X` are swappable.
137
 
138
  A type `X` meeting any of the iterator requirements
139
- [[iterator.requirements]] meets the *Cpp17ValueSwappable* requirements
140
- if, for any dereferenceable object `x` of type `X`, `*x` is swappable.
141
 
142
  [*Example 1*:
143
 
144
  User code can ensure that the evaluation of `swap` calls is performed in
145
  an appropriate context under the various conditions as follows:
@@ -189,25 +188,27 @@ int main() {
189
  — *end example*]
190
 
191
  #### *Cpp17NullablePointer* requirements <a id="nullablepointer.requirements">[[nullablepointer.requirements]]</a>
192
 
193
  A *Cpp17NullablePointer* type is a pointer-like type that supports null
194
- values. A type `P` meets the *Cpp17NullablePointer* requirements if:
195
 
196
  - `P` meets the *Cpp17EqualityComparable*, *Cpp17DefaultConstructible*,
197
  *Cpp17CopyConstructible*, *Cpp17CopyAssignable*, *Cpp17Swappable*, and
198
  *Cpp17Destructible* requirements,
199
  - the expressions shown in [[cpp17.nullablepointer]] are valid and have
200
  the indicated semantics, and
201
  - `P` meets all the other requirements of this subclause.
202
 
203
  A value-initialized object of type `P` produces the null value of the
204
  type. The null value shall be equivalent only to itself. A
205
- default-initialized object of type `P` may have an indeterminate value.
 
206
 
207
  [*Note 1*: Operations involving indeterminate values can cause
208
- undefined behavior. *end note*]
 
209
 
210
  An object `p` of type `P` can be contextually converted to `bool`
211
  [[conv]]. The effect shall be as if `p != nullptr` had been evaluated in
212
  place of `p`.
213
 
@@ -234,11 +235,11 @@ non-`const` lvalue of type `P`, `a` and `b` denote values of type
234
  | `np != a` | | |
235
 
236
 
237
  #### *Cpp17Hash* requirements <a id="hash.requirements">[[hash.requirements]]</a>
238
 
239
- A type `H` meets the requirements if:
240
 
241
  - it is a function object type [[function.objects]],
242
  - it meets the *Cpp17CopyConstructible* ([[cpp17.copyconstructible]])
243
  and *Cpp17Destructible* ([[cpp17.destructible]]) requirements, and
244
  - the expressions shown in [[cpp17.hash]] are valid and have the
@@ -261,15 +262,15 @@ The library describes a standard set of requirements for *allocators*,
261
  which are class-type objects that encapsulate the information about an
262
  allocation model. This information includes the knowledge of pointer
263
  types, the type of their difference, the type of the size of objects in
264
  this allocation model, as well as the memory allocation and deallocation
265
  primitives for it. All of the string types [[strings]], containers
266
- [[containers]] (except `array`), string buffers and string streams
267
- [[input.output]], and `match_results` [[re]] are parameterized in terms
268
- of allocators.
269
 
270
- In subclause [[allocator.requirements]],
271
 
272
  - `T`, `U`, `C` denote any cv-unqualified object type
273
  [[term.object.type]],
274
  - `X` denotes an allocator class for type `T`,
275
  - `Y` denotes the corresponding allocator class for type `U`,
@@ -365,11 +366,11 @@ typename X::difference_type
365
  between any two pointers in the allocation model.
366
 
367
  *Remarks:* Default: `pointer_traits<XX::pointer>::difference_type`
368
 
369
  ``` cpp
370
- typename X::template rebind<U>::other
371
  ```
372
 
373
  *Result:* `Y`
374
 
375
  *Ensures:* For all `U` (including `T`), `YY::rebind_alloc<T>` is `X`.
@@ -596,11 +597,11 @@ X u(std::move(b));
596
  *Ensures:* `u` is equal to the prior value of `X(b)`.
597
 
598
  *Throws:* Nothing.
599
 
600
  ``` cpp
601
- a.construct(c, args)
602
  ```
603
 
604
  *Result:* (not used)
605
 
606
  *Effects:* Constructs an object of type `C` at `c`.
@@ -765,10 +766,29 @@ struct SimpleAllocator {
765
  };
766
  ```
767
 
768
  — *end example*]
769
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
770
  ##### Allocator completeness requirements <a id="allocator.requirements.completeness">[[allocator.requirements.completeness]]</a>
771
 
772
  If `X` is an allocator class for type `T`, `X` additionally meets the
773
  allocator completeness requirements if, whether or not `T` is a complete
774
  type:
 
90
 
91
  **Table: Cpp17Destructible requirements** <a id="cpp17.destructible">[cpp17.destructible]</a>
92
 
93
  | Expression | Post-condition |
94
  | ---------- | --------------------------------------------------------------------- |
95
+ | `a.~T()` | All resources owned by `a` are reclaimed, no exception is propagated. |
96
  | *[spans 2 columns]* *Array types and non-object types are not Cpp17Destructible.* |
97
 
98
 
99
  #### Swappable requirements <a id="swappable.requirements">[[swappable.requirements]]</a>
100
 
101
  This subclause provides definitions for swappable types and expressions.
102
  In these definitions, let `t` denote an expression of type `T`, and let
103
  `u` denote an expression of type `U`.
104
 
105
+ An object `t` is *swappable with* an object `u` if and only if
106
 
107
  - the expressions `swap(t, u)` and `swap(u, t)` are valid when evaluated
108
  in the context described below, and
109
  - these expressions have the following effects:
110
  - the object referred to by `t` has the value originally held by `u`
 
130
  appropriate evaluation context. — *end note*]
131
 
132
  An rvalue or lvalue `t` is *swappable* if and only if `t` is swappable
133
  with any rvalue or lvalue, respectively, of type `T`.
134
 
135
+ A type `X` meets the requirements if lvalues of type `X` are swappable.
 
136
 
137
  A type `X` meeting any of the iterator requirements
138
+ [[iterator.requirements]] meets the requirements if, for any
139
+ dereferenceable object `x` of type `X`, `*x` is swappable.
140
 
141
  [*Example 1*:
142
 
143
  User code can ensure that the evaluation of `swap` calls is performed in
144
  an appropriate context under the various conditions as follows:
 
188
  — *end example*]
189
 
190
  #### *Cpp17NullablePointer* requirements <a id="nullablepointer.requirements">[[nullablepointer.requirements]]</a>
191
 
192
  A *Cpp17NullablePointer* type is a pointer-like type that supports null
193
+ values. A type `P` meets the *Cpp17NullablePointer* requirements if
194
 
195
  - `P` meets the *Cpp17EqualityComparable*, *Cpp17DefaultConstructible*,
196
  *Cpp17CopyConstructible*, *Cpp17CopyAssignable*, *Cpp17Swappable*, and
197
  *Cpp17Destructible* requirements,
198
  - the expressions shown in [[cpp17.nullablepointer]] are valid and have
199
  the indicated semantics, and
200
  - `P` meets all the other requirements of this subclause.
201
 
202
  A value-initialized object of type `P` produces the null value of the
203
  type. The null value shall be equivalent only to itself. A
204
+ default-initialized object of type `P` may have an indeterminate or
205
+ erroneous value.
206
 
207
  [*Note 1*: Operations involving indeterminate values can cause
208
+ undefined behavior, and operations involving erroneous values can cause
209
+ erroneous behavior [[basic.indet]]. — *end note*]
210
 
211
  An object `p` of type `P` can be contextually converted to `bool`
212
  [[conv]]. The effect shall be as if `p != nullptr` had been evaluated in
213
  place of `p`.
214
 
 
235
  | `np != a` | | |
236
 
237
 
238
  #### *Cpp17Hash* requirements <a id="hash.requirements">[[hash.requirements]]</a>
239
 
240
+ A type `H` meets the requirements if
241
 
242
  - it is a function object type [[function.objects]],
243
  - it meets the *Cpp17CopyConstructible* ([[cpp17.copyconstructible]])
244
  and *Cpp17Destructible* ([[cpp17.destructible]]) requirements, and
245
  - the expressions shown in [[cpp17.hash]] are valid and have the
 
262
  which are class-type objects that encapsulate the information about an
263
  allocation model. This information includes the knowledge of pointer
264
  types, the type of their difference, the type of the size of objects in
265
  this allocation model, as well as the memory allocation and deallocation
266
  primitives for it. All of the string types [[strings]], containers
267
+ [[containers]] (except `array` and `inplace_vector`), string buffers and
268
+ string streams [[input.output]], and `match_results` [[re]] are
269
+ parameterized in terms of allocators.
270
 
271
+ In [[allocator.requirements]],
272
 
273
  - `T`, `U`, `C` denote any cv-unqualified object type
274
  [[term.object.type]],
275
  - `X` denotes an allocator class for type `T`,
276
  - `Y` denotes the corresponding allocator class for type `U`,
 
366
  between any two pointers in the allocation model.
367
 
368
  *Remarks:* Default: `pointer_traits<XX::pointer>::difference_type`
369
 
370
  ``` cpp
371
+ typename X::rebind<U>::other
372
  ```
373
 
374
  *Result:* `Y`
375
 
376
  *Ensures:* For all `U` (including `T`), `YY::rebind_alloc<T>` is `X`.
 
597
  *Ensures:* `u` is equal to the prior value of `X(b)`.
598
 
599
  *Throws:* Nothing.
600
 
601
  ``` cpp
602
+ a.construct(c, args...)
603
  ```
604
 
605
  *Result:* (not used)
606
 
607
  *Effects:* Constructs an object of type `C` at `c`.
 
766
  };
767
  ```
768
 
769
  — *end example*]
770
 
771
+ The following exposition-only concept defines the minimal requirements
772
+ on an Allocator type.
773
+
774
+ ``` cpp
775
+ namespace std {
776
+ template<class Alloc>
777
+ concept simple-allocator =
778
+ requires(Alloc alloc, size_t n) {
779
+ { *alloc.allocate(n) } -> same_as<typename Alloc::value_type&>;
780
+ { alloc.deallocate(alloc.allocate(n), n) };
781
+ } &&
782
+ copy_constructible<Alloc> &&
783
+ equality_comparable<Alloc>;
784
+ }
785
+ ```
786
+
787
+ A type `Alloc` models `simple-allocator` if it meets the requirements of
788
+ [[allocator.requirements.general]].
789
+
790
  ##### Allocator completeness requirements <a id="allocator.requirements.completeness">[[allocator.requirements.completeness]]</a>
791
 
792
  If `X` is an allocator class for type `T`, `X` additionally meets the
793
  allocator completeness requirements if, whether or not `T` is a complete
794
  type: