From Jason Turner

[mem.poly.allocator.class]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpz9my2ycv/{from.md → to.md} +20 -10
tmp/tmpz9my2ycv/{from.md → to.md} RENAMED
@@ -35,23 +35,26 @@ namespace std::pmr {
35
  polymorphic_allocator(const polymorphic_allocator<U>& other) noexcept;
36
 
37
  polymorphic_allocator& operator=(const polymorphic_allocator&) = delete;
38
 
39
  // [mem.poly.allocator.mem], member functions
40
- [[nodiscard]] Tp* allocate(size_t n);
41
  void deallocate(Tp* p, size_t n);
42
 
43
- [[nodiscard]] void* allocate_bytes(size_t nbytes, size_t alignment = alignof(max_align_t));
44
  void deallocate_bytes(void* p, size_t nbytes, size_t alignment = alignof(max_align_t));
45
- template<class T> [[nodiscard]] T* allocate_object(size_t n = 1);
46
  template<class T> void deallocate_object(T* p, size_t n = 1);
47
- template<class T, class... CtorArgs> [[nodiscard]] T* new_object(CtorArgs&&... ctor_args);
48
  template<class T> void delete_object(T* p);
49
 
50
  template<class T, class... Args>
51
  void construct(T* p, Args&&... args);
52
 
 
 
 
53
  polymorphic_allocator select_on_container_copy_construction() const;
54
 
55
  memory_resource* resource() const;
56
 
57
  // friends
@@ -91,11 +94,11 @@ template<class U> polymorphic_allocator(const polymorphic_allocator<U>& other) n
91
  *Effects:* Sets `memory_rsrc` to `other.resource()`.
92
 
93
  #### Member functions <a id="mem.poly.allocator.mem">[[mem.poly.allocator.mem]]</a>
94
 
95
  ``` cpp
96
- [[nodiscard]] Tp* allocate(size_t n);
97
  ```
98
 
99
  *Effects:* If `numeric_limits<size_t>::max() / sizeof(Tp) < n`, throws
100
  `bad_array_new_length`. Otherwise equivalent to:
101
 
@@ -114,11 +117,11 @@ void deallocate(Tp* p, size_t n);
114
  `memory_rsrc->deallocate(p, n * sizeof(Tp), alignof(Tp))`.
115
 
116
  *Throws:* Nothing.
117
 
118
  ``` cpp
119
- [[nodiscard]] void* allocate_bytes(size_t nbytes, size_t alignment = alignof(max_align_t));
120
  ```
121
 
122
  *Effects:* Equivalent to:
123
  `return memory_rsrc->allocate(nbytes, alignment);`
124
 
@@ -134,11 +137,11 @@ void deallocate_bytes(void* p, size_t nbytes, size_t alignment = alignof(max_ali
134
  *Effects:* Equivalent to
135
  `memory_rsrc->deallocate(p, nbytes, alignment)`.
136
 
137
  ``` cpp
138
  template<class T>
139
- [[nodiscard]] T* allocate_object(size_t n = 1);
140
  ```
141
 
142
  *Effects:* Allocates memory suitable for holding an array of `n` objects
143
  of type `T`, as follows:
144
 
@@ -159,11 +162,11 @@ template<class T>
159
 
160
  *Effects:* Equivalent to `deallocate_bytes(p, n*sizeof(T), alignof(T))`.
161
 
162
  ``` cpp
163
  template<class T, class... CtorArgs>
164
- [[nodiscard]] T* new_object(CtorArgs&&... ctor_args);
165
  ```
166
 
167
  *Effects:* Allocates and constructs an object of type `T`, as follows.
168
  Equivalent to:
169
 
@@ -187,11 +190,11 @@ template<class T>
187
  ```
188
 
189
  *Effects:* Equivalent to:
190
 
191
  ``` cpp
192
- allocator_traits<polymorphic_allocator>::destroy(*this, p);
193
  deallocate_object(p);
194
  ```
195
 
196
  ``` cpp
197
  template<class T, class... Args>
@@ -200,16 +203,23 @@ template<class T, class... Args>
200
 
201
  *Mandates:* Uses-allocator construction of `T` with allocator `*this`
202
  (see  [[allocator.uses.construction]]) and constructor arguments
203
  `std::forward<Args>(args)...` is well-formed.
204
 
205
- *Effects:* Construct a `T` object in the storage whose address is
206
  represented by `p` by uses-allocator construction with allocator `*this`
207
  and constructor arguments `std::forward<Args>(args)...`.
208
 
209
  *Throws:* Nothing unless the constructor for `T` throws.
210
 
 
 
 
 
 
 
 
211
  ``` cpp
212
  polymorphic_allocator select_on_container_copy_construction() const;
213
  ```
214
 
215
  *Returns:* `polymorphic_allocator()`.
 
35
  polymorphic_allocator(const polymorphic_allocator<U>& other) noexcept;
36
 
37
  polymorphic_allocator& operator=(const polymorphic_allocator&) = delete;
38
 
39
  // [mem.poly.allocator.mem], member functions
40
+ Tp* allocate(size_t n);
41
  void deallocate(Tp* p, size_t n);
42
 
43
+ void* allocate_bytes(size_t nbytes, size_t alignment = alignof(max_align_t));
44
  void deallocate_bytes(void* p, size_t nbytes, size_t alignment = alignof(max_align_t));
45
+ template<class T> T* allocate_object(size_t n = 1);
46
  template<class T> void deallocate_object(T* p, size_t n = 1);
47
+ template<class T, class... CtorArgs> T* new_object(CtorArgs&&... ctor_args);
48
  template<class T> void delete_object(T* p);
49
 
50
  template<class T, class... Args>
51
  void construct(T* p, Args&&... args);
52
 
53
+ template<class T>
54
+ void destroy(T* p);
55
+
56
  polymorphic_allocator select_on_container_copy_construction() const;
57
 
58
  memory_resource* resource() const;
59
 
60
  // friends
 
94
  *Effects:* Sets `memory_rsrc` to `other.resource()`.
95
 
96
  #### Member functions <a id="mem.poly.allocator.mem">[[mem.poly.allocator.mem]]</a>
97
 
98
  ``` cpp
99
+ Tp* allocate(size_t n);
100
  ```
101
 
102
  *Effects:* If `numeric_limits<size_t>::max() / sizeof(Tp) < n`, throws
103
  `bad_array_new_length`. Otherwise equivalent to:
104
 
 
117
  `memory_rsrc->deallocate(p, n * sizeof(Tp), alignof(Tp))`.
118
 
119
  *Throws:* Nothing.
120
 
121
  ``` cpp
122
+ void* allocate_bytes(size_t nbytes, size_t alignment = alignof(max_align_t));
123
  ```
124
 
125
  *Effects:* Equivalent to:
126
  `return memory_rsrc->allocate(nbytes, alignment);`
127
 
 
137
  *Effects:* Equivalent to
138
  `memory_rsrc->deallocate(p, nbytes, alignment)`.
139
 
140
  ``` cpp
141
  template<class T>
142
+ T* allocate_object(size_t n = 1);
143
  ```
144
 
145
  *Effects:* Allocates memory suitable for holding an array of `n` objects
146
  of type `T`, as follows:
147
 
 
162
 
163
  *Effects:* Equivalent to `deallocate_bytes(p, n*sizeof(T), alignof(T))`.
164
 
165
  ``` cpp
166
  template<class T, class... CtorArgs>
167
+ T* new_object(CtorArgs&&... ctor_args);
168
  ```
169
 
170
  *Effects:* Allocates and constructs an object of type `T`, as follows.
171
  Equivalent to:
172
 
 
190
  ```
191
 
192
  *Effects:* Equivalent to:
193
 
194
  ``` cpp
195
+ destroy(p);
196
  deallocate_object(p);
197
  ```
198
 
199
  ``` cpp
200
  template<class T, class... Args>
 
203
 
204
  *Mandates:* Uses-allocator construction of `T` with allocator `*this`
205
  (see  [[allocator.uses.construction]]) and constructor arguments
206
  `std::forward<Args>(args)...` is well-formed.
207
 
208
+ *Effects:* Constructs a `T` object in the storage whose address is
209
  represented by `p` by uses-allocator construction with allocator `*this`
210
  and constructor arguments `std::forward<Args>(args)...`.
211
 
212
  *Throws:* Nothing unless the constructor for `T` throws.
213
 
214
+ ``` cpp
215
+ template<class T>
216
+ void destroy(T* p);
217
+ ```
218
+
219
+ *Effects:* Equivalent to `p->T̃()`.
220
+
221
  ``` cpp
222
  polymorphic_allocator select_on_container_copy_construction() const;
223
  ```
224
 
225
  *Returns:* `polymorphic_allocator()`.