From Jason Turner

[default.allocator]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmptrj2gcvt/{from.md → to.md} +30 -30
tmp/tmptrj2gcvt/{from.md → to.md} RENAMED
@@ -1,75 +1,75 @@
1
  ### The default allocator <a id="default.allocator">[[default.allocator]]</a>
2
 
3
- All specializations of the default allocator satisfy the allocator
4
- completeness requirements ([[allocator.requirements.completeness]]).
5
 
6
  ``` cpp
7
  namespace std {
8
  template<class T> class allocator {
9
  public:
10
  using value_type = T;
 
 
11
  using propagate_on_container_move_assignment = true_type;
12
  using is_always_equal = true_type;
13
 
14
- allocator() noexcept;
15
- allocator(const allocator&) noexcept;
16
- template <class U> allocator(const allocator<U>&) noexcept;
17
- ~allocator();
 
18
 
19
- T* allocate(size_t n);
20
- void deallocate(T* p, size_t n);
21
  };
22
  }
23
  ```
24
 
25
- #### `allocator` members <a id="allocator.members">[[allocator.members]]</a>
26
 
27
  Except for the destructor, member functions of the default allocator
28
- shall not introduce data races ([[intro.multithread]]) as a result of
29
  concurrent calls to those member functions from different threads. Calls
30
  to these functions that allocate or deallocate a particular unit of
31
  storage shall occur in a single total order, and each such deallocation
32
  call shall happen before the next allocation (if any) in this order.
33
 
34
  ``` cpp
35
- T* allocate(size_t n);
36
  ```
37
 
38
- *Returns:* A pointer to the initial element of an array of storage of
39
- size `n` `* sizeof(T)`, aligned appropriately for objects of type `T`.
40
 
41
- *Remarks:* the storage is obtained by calling
42
- `::operator new` ([[new.delete]]), but it is unspecified when or how
43
- often this function is called.
44
 
45
- *Throws:* `bad_alloc` if the storage cannot be obtained.
 
 
 
 
 
 
 
46
 
47
  ``` cpp
48
- void deallocate(T* p, size_t n);
49
  ```
50
 
51
- *Requires:* `p` shall be a pointer value obtained from `allocate()`. `n`
52
- shall equal the value passed as the first argument to the invocation of
53
  allocate which returned `p`.
54
 
55
  *Effects:* Deallocates the storage referenced by `p` .
56
 
57
- *Remarks:* Uses `::operator delete` ([[new.delete]]), but it is
58
  unspecified when this function is called.
59
 
60
- #### `allocator` globals <a id="allocator.globals">[[allocator.globals]]</a>
61
 
62
  ``` cpp
63
  template<class T, class U>
64
- bool operator==(const allocator<T>&, const allocator<U>&) noexcept;
65
  ```
66
 
67
  *Returns:* `true`.
68
 
69
- ``` cpp
70
- template <class T, class U>
71
- bool operator!=(const allocator<T>&, const allocator<U>&) noexcept;
72
- ```
73
-
74
- *Returns:* `false`.
75
-
 
1
  ### The default allocator <a id="default.allocator">[[default.allocator]]</a>
2
 
3
+ All specializations of the default allocator meet the allocator
4
+ completeness requirements [[allocator.requirements.completeness]].
5
 
6
  ``` cpp
7
  namespace std {
8
  template<class T> class allocator {
9
  public:
10
  using value_type = T;
11
+ using size_type = size_t;
12
+ using difference_type = ptrdiff_t;
13
  using propagate_on_container_move_assignment = true_type;
14
  using is_always_equal = true_type;
15
 
16
+ constexpr allocator() noexcept;
17
+ constexpr allocator(const allocator&) noexcept;
18
+ template<class U> constexpr allocator(const allocator<U>&) noexcept;
19
+ constexpr ~allocator();
20
+ constexpr allocator& operator=(const allocator&) = default;
21
 
22
+ [[nodiscard]] constexpr T* allocate(size_t n);
23
+ constexpr void deallocate(T* p, size_t n);
24
  };
25
  }
26
  ```
27
 
28
+ #### Members <a id="allocator.members">[[allocator.members]]</a>
29
 
30
  Except for the destructor, member functions of the default allocator
31
+ shall not introduce data races [[intro.multithread]] as a result of
32
  concurrent calls to those member functions from different threads. Calls
33
  to these functions that allocate or deallocate a particular unit of
34
  storage shall occur in a single total order, and each such deallocation
35
  call shall happen before the next allocation (if any) in this order.
36
 
37
  ``` cpp
38
+ [[nodiscard]] constexpr T* allocate(size_t n);
39
  ```
40
 
41
+ *Mandates:* `T` is not an incomplete type [[basic.types]].
 
42
 
43
+ *Returns:* A pointer to the initial element of an array of `n` `T`.
 
 
44
 
45
+ *Remarks:* The storage for the array is obtained by calling
46
+ `::operator new` [[new.delete]], but it is unspecified when or how often
47
+ this function is called. This function starts the lifetime of the array
48
+ object, but not that of any of the array elements.
49
+
50
+ *Throws:* `bad_array_new_length` if
51
+ `numeric_limits<size_t>::max() / sizeof(T) < n`, or `bad_alloc` if the
52
+ storage cannot be obtained.
53
 
54
  ``` cpp
55
+ constexpr void deallocate(T* p, size_t n);
56
  ```
57
 
58
+ *Preconditions:* `p` is a pointer value obtained from `allocate()`. `n`
59
+ equals the value passed as the first argument to the invocation of
60
  allocate which returned `p`.
61
 
62
  *Effects:* Deallocates the storage referenced by `p` .
63
 
64
+ *Remarks:* Uses `::operator delete` [[new.delete]], but it is
65
  unspecified when this function is called.
66
 
67
+ #### Operators <a id="allocator.globals">[[allocator.globals]]</a>
68
 
69
  ``` cpp
70
  template<class T, class U>
71
+ constexpr bool operator==(const allocator<T>&, const allocator<U>&) noexcept;
72
  ```
73
 
74
  *Returns:* `true`.
75