tmp/tmp7t4d3a0x/{from.md → to.md}
RENAMED
|
@@ -4,15 +4,15 @@ The library describes a standard set of requirements for *allocators*,
|
|
| 4 |
which are class-type objects that encapsulate the information about an
|
| 5 |
allocation model. This information includes the knowledge of pointer
|
| 6 |
types, the type of their difference, the type of the size of objects in
|
| 7 |
this allocation model, as well as the memory allocation and deallocation
|
| 8 |
primitives for it. All of the string types [[strings]], containers
|
| 9 |
-
[[containers]] (except `array`), string buffers and
|
| 10 |
-
[[input.output]], and `match_results` [[re]] are
|
| 11 |
-
of allocators.
|
| 12 |
|
| 13 |
-
In
|
| 14 |
|
| 15 |
- `T`, `U`, `C` denote any cv-unqualified object type
|
| 16 |
[[term.object.type]],
|
| 17 |
- `X` denotes an allocator class for type `T`,
|
| 18 |
- `Y` denotes the corresponding allocator class for type `U`,
|
|
@@ -108,11 +108,11 @@ typename X::difference_type
|
|
| 108 |
between any two pointers in the allocation model.
|
| 109 |
|
| 110 |
*Remarks:* Default: `pointer_traits<XX::pointer>::difference_type`
|
| 111 |
|
| 112 |
``` cpp
|
| 113 |
-
typename X::
|
| 114 |
```
|
| 115 |
|
| 116 |
*Result:* `Y`
|
| 117 |
|
| 118 |
*Ensures:* For all `U` (including `T`), `YY::rebind_alloc<T>` is `X`.
|
|
@@ -339,11 +339,11 @@ X u(std::move(b));
|
|
| 339 |
*Ensures:* `u` is equal to the prior value of `X(b)`.
|
| 340 |
|
| 341 |
*Throws:* Nothing.
|
| 342 |
|
| 343 |
``` cpp
|
| 344 |
-
a.construct(c, args)
|
| 345 |
```
|
| 346 |
|
| 347 |
*Result:* (not used)
|
| 348 |
|
| 349 |
*Effects:* Constructs an object of type `C` at `c`.
|
|
@@ -508,5 +508,24 @@ struct SimpleAllocator {
|
|
| 508 |
};
|
| 509 |
```
|
| 510 |
|
| 511 |
— *end example*]
|
| 512 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
which are class-type objects that encapsulate the information about an
|
| 5 |
allocation model. This information includes the knowledge of pointer
|
| 6 |
types, the type of their difference, the type of the size of objects in
|
| 7 |
this allocation model, as well as the memory allocation and deallocation
|
| 8 |
primitives for it. All of the string types [[strings]], containers
|
| 9 |
+
[[containers]] (except `array` and `inplace_vector`), string buffers and
|
| 10 |
+
string streams [[input.output]], and `match_results` [[re]] are
|
| 11 |
+
parameterized in terms of allocators.
|
| 12 |
|
| 13 |
+
In [[allocator.requirements]],
|
| 14 |
|
| 15 |
- `T`, `U`, `C` denote any cv-unqualified object type
|
| 16 |
[[term.object.type]],
|
| 17 |
- `X` denotes an allocator class for type `T`,
|
| 18 |
- `Y` denotes the corresponding allocator class for type `U`,
|
|
|
|
| 108 |
between any two pointers in the allocation model.
|
| 109 |
|
| 110 |
*Remarks:* Default: `pointer_traits<XX::pointer>::difference_type`
|
| 111 |
|
| 112 |
``` cpp
|
| 113 |
+
typename X::rebind<U>::other
|
| 114 |
```
|
| 115 |
|
| 116 |
*Result:* `Y`
|
| 117 |
|
| 118 |
*Ensures:* For all `U` (including `T`), `YY::rebind_alloc<T>` is `X`.
|
|
|
|
| 339 |
*Ensures:* `u` is equal to the prior value of `X(b)`.
|
| 340 |
|
| 341 |
*Throws:* Nothing.
|
| 342 |
|
| 343 |
``` cpp
|
| 344 |
+
a.construct(c, args...)
|
| 345 |
```
|
| 346 |
|
| 347 |
*Result:* (not used)
|
| 348 |
|
| 349 |
*Effects:* Constructs an object of type `C` at `c`.
|
|
|
|
| 508 |
};
|
| 509 |
```
|
| 510 |
|
| 511 |
— *end example*]
|
| 512 |
|
| 513 |
+
The following exposition-only concept defines the minimal requirements
|
| 514 |
+
on an Allocator type.
|
| 515 |
+
|
| 516 |
+
``` cpp
|
| 517 |
+
namespace std {
|
| 518 |
+
template<class Alloc>
|
| 519 |
+
concept simple-allocator =
|
| 520 |
+
requires(Alloc alloc, size_t n) {
|
| 521 |
+
{ *alloc.allocate(n) } -> same_as<typename Alloc::value_type&>;
|
| 522 |
+
{ alloc.deallocate(alloc.allocate(n), n) };
|
| 523 |
+
} &&
|
| 524 |
+
copy_constructible<Alloc> &&
|
| 525 |
+
equality_comparable<Alloc>;
|
| 526 |
+
}
|
| 527 |
+
```
|
| 528 |
+
|
| 529 |
+
A type `Alloc` models `simple-allocator` if it meets the requirements of
|
| 530 |
+
[[allocator.requirements.general]].
|
| 531 |
+
|