From Jason Turner

[allocator.requirements]

Diff to HTML by rtfpessoa

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