From Jason Turner

[utility.requirements]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpxfx9td8l/{from.md → to.md} +57 -14
tmp/tmpxfx9td8l/{from.md → to.md} RENAMED
@@ -77,15 +77,15 @@ signatures is called using the default argument ([[dcl.fct.default]]).
77
 
78
 
79
  **Table: `Destructible` requirements** <a id="destructible">[destructible]</a>
80
 
81
  | | |
82
- | ------------- | --------------------------------------------------------------------- |
83
- | `u.$\sim$T()` | All resources owned by `u` are reclaimed, no exception is propagated. |
84
 
85
 
86
- #### Swappable requirements <a id="swappable.requirements">[[swappable.requirements]]</a>
87
 
88
  This subclause provides definitions for swappable types and expressions.
89
  In these definitions, let `t` denote an expression of type `T`, and let
90
  `u` denote an expression of type `U`.
91
 
@@ -119,12 +119,13 @@ evaluation context.
119
 
120
  An rvalue or lvalue `t` is *swappable* if and only if `t` is swappable
121
  with any rvalue or lvalue, respectively, of type `T`.
122
 
123
  A type `X` satisfying any of the iterator requirements (
124
- [[iterator.requirements]]) is *ValueSwappable* if, for any
125
- dereferenceable object `x` of type `X`, `*x` is swappable.
 
126
 
127
  User code can ensure that the evaluation of `swap` calls is performed in
128
  an appropriate context under the various conditions as follows:
129
 
130
  ``` cpp
@@ -229,12 +230,12 @@ lvalue of type `Key`, and `k` is a value of a type convertible to
229
  (possibly `const`) `Key`.
230
 
231
  **Table: `Hash` requirements** <a id="hash">[hash]</a>
232
 
233
  | | | |
234
- | ------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
235
- | `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 |
236
  | `h(u)` | `size_t` | Shall not modify `u`. |
237
 
238
 
239
  #### Allocator requirements <a id="allocator.requirements">[[allocator.requirements]]</a>
240
 
@@ -274,17 +275,54 @@ class template instantiation of the form `SomeAllocator<T, Args>`, where
274
  `rebind` member template, the standard `allocator_traits` template uses
275
  `SomeAllocator<U, Args>` in place of `Allocator::{}rebind<U>::other` by
276
  default. For allocator types that are not template instantiations of the
277
  above form, no default is provided.
278
 
279
- The `X::pointer`, `X::const_pointer`, `X::void_pointer`, and
280
- `X::const_void_pointer` types shall satisfy the requirements of
281
- `NullablePointer` ([[nullablepointer.requirements]]). No constructor,
282
- comparison operator, copy operation, move operation, or swap operation
283
- on these types shall exit via an exception. `X::pointer` and
284
- `X::const_pointer` shall also satisfy the requirements for a random
285
- access iterator ([[iterator.requirements]]).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
 
287
  An allocator may constrain the types on which it can be instantiated and
288
  the arguments for which its `construct` member may be called. If a type
289
  cannot be used with a particular allocator, the allocator class or the
290
  call to `construct` may fail to instantiate.
@@ -302,10 +340,15 @@ struct SimpleAllocator {
302
  template <class T> SimpleAllocator(const SimpleAllocator<T>& other);
303
 
304
  Tp* allocate(std::size_t n);
305
  void deallocate(Tp* p, std::size_t n);
306
  };
 
 
 
 
 
307
  ```
308
 
309
  If the alignment associated with a specific over-aligned type is not
310
  supported by an allocator, instantiation of the allocator for that type
311
  may fail. The allocator also may silently ignore the requested
 
77
 
78
 
79
  **Table: `Destructible` requirements** <a id="destructible">[destructible]</a>
80
 
81
  | | |
82
+ | -------- | --------------------------------------------------------------------- |
83
+ | `u.~T()` | All resources owned by `u` are reclaimed, no exception is propagated. |
84
 
85
 
86
+ #### `Swappable` requirements <a id="swappable.requirements">[[swappable.requirements]]</a>
87
 
88
  This subclause provides definitions for swappable types and expressions.
89
  In these definitions, let `t` denote an expression of type `T`, and let
90
  `u` denote an expression of type `U`.
91
 
 
119
 
120
  An rvalue or lvalue `t` is *swappable* if and only if `t` is swappable
121
  with any rvalue or lvalue, respectively, of type `T`.
122
 
123
  A type `X` satisfying any of the iterator requirements (
124
+ [[iterator.requirements]]) satisfies the requirements of
125
+ `ValueSwappable` if, for any dereferenceable object `x` of type `X`,
126
+ `*x` is swappable.
127
 
128
  User code can ensure that the evaluation of `swap` calls is performed in
129
  an appropriate context under the various conditions as follows:
130
 
131
  ``` cpp
 
230
  (possibly `const`) `Key`.
231
 
232
  **Table: `Hash` requirements** <a id="hash">[hash]</a>
233
 
234
  | | | |
235
+ | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
236
+ | `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 |
237
  | `h(u)` | `size_t` | Shall not modify `u`. |
238
 
239
 
240
  #### Allocator requirements <a id="allocator.requirements">[[allocator.requirements]]</a>
241
 
 
275
  `rebind` member template, the standard `allocator_traits` template uses
276
  `SomeAllocator<U, Args>` in place of `Allocator::{}rebind<U>::other` by
277
  default. For allocator types that are not template instantiations of the
278
  above form, no default is provided.
279
 
280
+ An allocator type `X` shall satisfy the requirements of
281
+ `CopyConstructible` ([[utility.arg.requirements]]). The `X::pointer`,
282
+ `X::const_pointer`, `X::void_pointer`, and `X::const_void_pointer` types
283
+ shall satisfy the requirements of `NullablePointer` (
284
+ [[nullablepointer.requirements]]). No constructor, comparison operator,
285
+ copy operation, move operation, or swap operation on these types shall
286
+ exit via an exception. `X::pointer` and `X::const_pointer` shall also
287
+ satisfy the requirements for a random access iterator (
288
+ [[iterator.requirements]]).
289
+
290
+ Let `x1` and `x2` denote objects of (possibly different) types
291
+ `X::void_pointer`, `X::const_void_pointer`, `X::pointer`, or
292
+ `X::const_pointer`. Then, `x1` and `x2` are *equivalently-valued*
293
+ pointer values, if and only if both `x1` and `x2` can be explicitly
294
+ converted to the two corresponding objects `px1` and `px2` of type
295
+ `X::const_pointer`, using a sequence of `static_cast`s using only these
296
+ four types, and the expression `px1 == px2` evaluates to `true`.
297
+
298
+ Let `w1` and `w2` denote objects of type `X::void_pointer`. Then for the
299
+ expressions
300
+
301
+ ``` cpp
302
+ w1 == w2
303
+ w1 != w2
304
+ ```
305
+
306
+ either or both objects may be replaced by an equivalently-valued object
307
+ of type `X::const_void_pointer` with no change in semantics.
308
+
309
+ Let `p1` and `p2` denote objects of type `X::pointer`. Then for the
310
+ expressions
311
+
312
+ ``` cpp
313
+ p1 == p2
314
+ p1 != p2
315
+ p1 < p2
316
+ p1 <= p2
317
+ p1 >= p2
318
+ p1 > p2
319
+ p1 - p2
320
+ ```
321
+
322
+ either or both objects may be replaced by an equivalently-valued object
323
+ of type `X::const_pointer` with no change in semantics.
324
 
325
  An allocator may constrain the types on which it can be instantiated and
326
  the arguments for which its `construct` member may be called. If a type
327
  cannot be used with a particular allocator, the allocator class or the
328
  call to `construct` may fail to instantiate.
 
340
  template <class T> SimpleAllocator(const SimpleAllocator<T>& other);
341
 
342
  Tp* allocate(std::size_t n);
343
  void deallocate(Tp* p, std::size_t n);
344
  };
345
+
346
+ template <class T, class U>
347
+ bool operator==(const SimpleAllocator<T>&, const SimpleAllocator<U>&);
348
+ template <class T, class U>
349
+ bool operator!=(const SimpleAllocator<T>&, const SimpleAllocator<U>&);
350
  ```
351
 
352
  If the alignment associated with a specific over-aligned type is not
353
  supported by an allocator, instantiation of the allocator for that type
354
  may fail. The allocator also may silently ignore the requested