tmp/tmpz80e0ywa/{from.md → to.md}
RENAMED
|
@@ -47,11 +47,11 @@ namespace std::pmr {
|
|
| 47 |
memory_resource(const memory_resource&) = default;
|
| 48 |
virtual ~memory_resource();
|
| 49 |
|
| 50 |
memory_resource& operator=(const memory_resource&) = default;
|
| 51 |
|
| 52 |
-
|
| 53 |
void deallocate(void* p, size_t bytes, size_t alignment = max_align);
|
| 54 |
|
| 55 |
bool is_equal(const memory_resource& other) const noexcept;
|
| 56 |
|
| 57 |
private:
|
|
@@ -70,11 +70,11 @@ namespace std::pmr {
|
|
| 70 |
```
|
| 71 |
|
| 72 |
*Effects:* Destroys this `memory_resource`.
|
| 73 |
|
| 74 |
``` cpp
|
| 75 |
-
|
| 76 |
```
|
| 77 |
|
| 78 |
*Effects:* Allocates storage by calling `do_allocate(bytes, alignment)`
|
| 79 |
and implicitly creates objects within the allocated region of storage.
|
| 80 |
|
|
@@ -127,16 +127,16 @@ allocated storage.
|
|
| 127 |
``` cpp
|
| 128 |
virtual bool do_is_equal(const memory_resource& other) const noexcept = 0;
|
| 129 |
```
|
| 130 |
|
| 131 |
*Returns:* A derived class shall implement this function to return
|
| 132 |
-
`true` if memory allocated from `this` can be deallocated from `other`
|
| 133 |
and vice-versa, otherwise `false`.
|
| 134 |
|
| 135 |
[*Note 1*: It is possible that the most-derived type of `other` does
|
| 136 |
-
not match the type of `this`. For a derived class `D`, an
|
| 137 |
-
of this function can immediately return `false` if
|
| 138 |
`dynamic_cast<const D*>(&other) == nullptr`. — *end note*]
|
| 139 |
|
| 140 |
#### Equality <a id="mem.res.eq">[[mem.res.eq]]</a>
|
| 141 |
|
| 142 |
``` cpp
|
|
@@ -182,23 +182,26 @@ namespace std::pmr {
|
|
| 182 |
polymorphic_allocator(const polymorphic_allocator<U>& other) noexcept;
|
| 183 |
|
| 184 |
polymorphic_allocator& operator=(const polymorphic_allocator&) = delete;
|
| 185 |
|
| 186 |
// [mem.poly.allocator.mem], member functions
|
| 187 |
-
|
| 188 |
void deallocate(Tp* p, size_t n);
|
| 189 |
|
| 190 |
-
|
| 191 |
void deallocate_bytes(void* p, size_t nbytes, size_t alignment = alignof(max_align_t));
|
| 192 |
-
template<class T>
|
| 193 |
template<class T> void deallocate_object(T* p, size_t n = 1);
|
| 194 |
-
template<class T, class... CtorArgs>
|
| 195 |
template<class T> void delete_object(T* p);
|
| 196 |
|
| 197 |
template<class T, class... Args>
|
| 198 |
void construct(T* p, Args&&... args);
|
| 199 |
|
|
|
|
|
|
|
|
|
|
| 200 |
polymorphic_allocator select_on_container_copy_construction() const;
|
| 201 |
|
| 202 |
memory_resource* resource() const;
|
| 203 |
|
| 204 |
// friends
|
|
@@ -238,11 +241,11 @@ template<class U> polymorphic_allocator(const polymorphic_allocator<U>& other) n
|
|
| 238 |
*Effects:* Sets `memory_rsrc` to `other.resource()`.
|
| 239 |
|
| 240 |
#### Member functions <a id="mem.poly.allocator.mem">[[mem.poly.allocator.mem]]</a>
|
| 241 |
|
| 242 |
``` cpp
|
| 243 |
-
|
| 244 |
```
|
| 245 |
|
| 246 |
*Effects:* If `numeric_limits<size_t>::max() / sizeof(Tp) < n`, throws
|
| 247 |
`bad_array_new_length`. Otherwise equivalent to:
|
| 248 |
|
|
@@ -261,11 +264,11 @@ void deallocate(Tp* p, size_t n);
|
|
| 261 |
`memory_rsrc->deallocate(p, n * sizeof(Tp), alignof(Tp))`.
|
| 262 |
|
| 263 |
*Throws:* Nothing.
|
| 264 |
|
| 265 |
``` cpp
|
| 266 |
-
|
| 267 |
```
|
| 268 |
|
| 269 |
*Effects:* Equivalent to:
|
| 270 |
`return memory_rsrc->allocate(nbytes, alignment);`
|
| 271 |
|
|
@@ -281,11 +284,11 @@ void deallocate_bytes(void* p, size_t nbytes, size_t alignment = alignof(max_ali
|
|
| 281 |
*Effects:* Equivalent to
|
| 282 |
`memory_rsrc->deallocate(p, nbytes, alignment)`.
|
| 283 |
|
| 284 |
``` cpp
|
| 285 |
template<class T>
|
| 286 |
-
|
| 287 |
```
|
| 288 |
|
| 289 |
*Effects:* Allocates memory suitable for holding an array of `n` objects
|
| 290 |
of type `T`, as follows:
|
| 291 |
|
|
@@ -306,11 +309,11 @@ template<class T>
|
|
| 306 |
|
| 307 |
*Effects:* Equivalent to `deallocate_bytes(p, n*sizeof(T), alignof(T))`.
|
| 308 |
|
| 309 |
``` cpp
|
| 310 |
template<class T, class... CtorArgs>
|
| 311 |
-
|
| 312 |
```
|
| 313 |
|
| 314 |
*Effects:* Allocates and constructs an object of type `T`, as follows.
|
| 315 |
Equivalent to:
|
| 316 |
|
|
@@ -334,11 +337,11 @@ template<class T>
|
|
| 334 |
```
|
| 335 |
|
| 336 |
*Effects:* Equivalent to:
|
| 337 |
|
| 338 |
``` cpp
|
| 339 |
-
|
| 340 |
deallocate_object(p);
|
| 341 |
```
|
| 342 |
|
| 343 |
``` cpp
|
| 344 |
template<class T, class... Args>
|
|
@@ -347,16 +350,23 @@ template<class T, class... Args>
|
|
| 347 |
|
| 348 |
*Mandates:* Uses-allocator construction of `T` with allocator `*this`
|
| 349 |
(see [[allocator.uses.construction]]) and constructor arguments
|
| 350 |
`std::forward<Args>(args)...` is well-formed.
|
| 351 |
|
| 352 |
-
*Effects:*
|
| 353 |
represented by `p` by uses-allocator construction with allocator `*this`
|
| 354 |
and constructor arguments `std::forward<Args>(args)...`.
|
| 355 |
|
| 356 |
*Throws:* Nothing unless the constructor for `T` throws.
|
| 357 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 358 |
``` cpp
|
| 359 |
polymorphic_allocator select_on_container_copy_construction() const;
|
| 360 |
```
|
| 361 |
|
| 362 |
*Returns:* `polymorphic_allocator()`.
|
|
@@ -415,13 +425,13 @@ resource pointer to `r`, otherwise sets the default memory resource
|
|
| 415 |
pointer to `new_delete_resource()`.
|
| 416 |
|
| 417 |
*Returns:* The previous value of the default memory resource pointer.
|
| 418 |
|
| 419 |
*Remarks:* Calling the `set_default_resource` and `get_default_resource`
|
| 420 |
-
functions shall not incur a data race. A call to the
|
| 421 |
-
`set_default_resource` function
|
| 422 |
-
|
| 423 |
|
| 424 |
``` cpp
|
| 425 |
memory_resource* get_default_resource() noexcept;
|
| 426 |
```
|
| 427 |
|
|
@@ -538,11 +548,11 @@ size_t max_blocks_per_chunk;
|
|
| 538 |
The maximum number of blocks that will be allocated at once from the
|
| 539 |
upstream memory resource [[mem.res.monotonic.buffer]] to replenish a
|
| 540 |
pool. If the value of `max_blocks_per_chunk` is zero or is greater than
|
| 541 |
an *implementation-defined* limit, that limit is used instead. The
|
| 542 |
implementation may choose to use a smaller value than is specified in
|
| 543 |
-
this
|
| 544 |
|
| 545 |
``` cpp
|
| 546 |
size_t largest_required_pool_block;
|
| 547 |
```
|
| 548 |
|
|
@@ -550,11 +560,11 @@ The largest allocation size that is required to be fulfilled using the
|
|
| 550 |
pooling mechanism. Attempts to allocate a single block larger than this
|
| 551 |
threshold will be allocated directly from the upstream memory resource.
|
| 552 |
If `largest_required_pool_block` is zero or is greater than an
|
| 553 |
*implementation-defined* limit, that limit is used instead. The
|
| 554 |
implementation may choose a pass-through threshold larger than specified
|
| 555 |
-
in this
|
| 556 |
|
| 557 |
#### Constructors and destructors <a id="mem.res.pool.ctor">[[mem.res.pool.ctor]]</a>
|
| 558 |
|
| 559 |
``` cpp
|
| 560 |
synchronized_pool_resource(const pool_options& opts, memory_resource* upstream);
|
|
@@ -739,12 +749,12 @@ void release();
|
|
| 739 |
*Effects:* Calls `upstream_rsrc->deallocate()` as necessary to release
|
| 740 |
all allocated memory. Resets `current_buffer` and `next_buffer_size` to
|
| 741 |
their initial values at construction.
|
| 742 |
|
| 743 |
[*Note 1*: The memory is released back to `upstream_rsrc` even if some
|
| 744 |
-
blocks that were allocated from `this` have not been deallocated from
|
| 745 |
-
`this`. — *end note*]
|
| 746 |
|
| 747 |
``` cpp
|
| 748 |
memory_resource* upstream_resource() const;
|
| 749 |
```
|
| 750 |
|
|
|
|
| 47 |
memory_resource(const memory_resource&) = default;
|
| 48 |
virtual ~memory_resource();
|
| 49 |
|
| 50 |
memory_resource& operator=(const memory_resource&) = default;
|
| 51 |
|
| 52 |
+
void* allocate(size_t bytes, size_t alignment = max_align);
|
| 53 |
void deallocate(void* p, size_t bytes, size_t alignment = max_align);
|
| 54 |
|
| 55 |
bool is_equal(const memory_resource& other) const noexcept;
|
| 56 |
|
| 57 |
private:
|
|
|
|
| 70 |
```
|
| 71 |
|
| 72 |
*Effects:* Destroys this `memory_resource`.
|
| 73 |
|
| 74 |
``` cpp
|
| 75 |
+
void* allocate(size_t bytes, size_t alignment = max_align);
|
| 76 |
```
|
| 77 |
|
| 78 |
*Effects:* Allocates storage by calling `do_allocate(bytes, alignment)`
|
| 79 |
and implicitly creates objects within the allocated region of storage.
|
| 80 |
|
|
|
|
| 127 |
``` cpp
|
| 128 |
virtual bool do_is_equal(const memory_resource& other) const noexcept = 0;
|
| 129 |
```
|
| 130 |
|
| 131 |
*Returns:* A derived class shall implement this function to return
|
| 132 |
+
`true` if memory allocated from `*this` can be deallocated from `other`
|
| 133 |
and vice-versa, otherwise `false`.
|
| 134 |
|
| 135 |
[*Note 1*: It is possible that the most-derived type of `other` does
|
| 136 |
+
not match the type of `*this`. For a derived class `D`, an
|
| 137 |
+
implementation of this function can immediately return `false` if
|
| 138 |
`dynamic_cast<const D*>(&other) == nullptr`. — *end note*]
|
| 139 |
|
| 140 |
#### Equality <a id="mem.res.eq">[[mem.res.eq]]</a>
|
| 141 |
|
| 142 |
``` cpp
|
|
|
|
| 182 |
polymorphic_allocator(const polymorphic_allocator<U>& other) noexcept;
|
| 183 |
|
| 184 |
polymorphic_allocator& operator=(const polymorphic_allocator&) = delete;
|
| 185 |
|
| 186 |
// [mem.poly.allocator.mem], member functions
|
| 187 |
+
Tp* allocate(size_t n);
|
| 188 |
void deallocate(Tp* p, size_t n);
|
| 189 |
|
| 190 |
+
void* allocate_bytes(size_t nbytes, size_t alignment = alignof(max_align_t));
|
| 191 |
void deallocate_bytes(void* p, size_t nbytes, size_t alignment = alignof(max_align_t));
|
| 192 |
+
template<class T> T* allocate_object(size_t n = 1);
|
| 193 |
template<class T> void deallocate_object(T* p, size_t n = 1);
|
| 194 |
+
template<class T, class... CtorArgs> T* new_object(CtorArgs&&... ctor_args);
|
| 195 |
template<class T> void delete_object(T* p);
|
| 196 |
|
| 197 |
template<class T, class... Args>
|
| 198 |
void construct(T* p, Args&&... args);
|
| 199 |
|
| 200 |
+
template<class T>
|
| 201 |
+
void destroy(T* p);
|
| 202 |
+
|
| 203 |
polymorphic_allocator select_on_container_copy_construction() const;
|
| 204 |
|
| 205 |
memory_resource* resource() const;
|
| 206 |
|
| 207 |
// friends
|
|
|
|
| 241 |
*Effects:* Sets `memory_rsrc` to `other.resource()`.
|
| 242 |
|
| 243 |
#### Member functions <a id="mem.poly.allocator.mem">[[mem.poly.allocator.mem]]</a>
|
| 244 |
|
| 245 |
``` cpp
|
| 246 |
+
Tp* allocate(size_t n);
|
| 247 |
```
|
| 248 |
|
| 249 |
*Effects:* If `numeric_limits<size_t>::max() / sizeof(Tp) < n`, throws
|
| 250 |
`bad_array_new_length`. Otherwise equivalent to:
|
| 251 |
|
|
|
|
| 264 |
`memory_rsrc->deallocate(p, n * sizeof(Tp), alignof(Tp))`.
|
| 265 |
|
| 266 |
*Throws:* Nothing.
|
| 267 |
|
| 268 |
``` cpp
|
| 269 |
+
void* allocate_bytes(size_t nbytes, size_t alignment = alignof(max_align_t));
|
| 270 |
```
|
| 271 |
|
| 272 |
*Effects:* Equivalent to:
|
| 273 |
`return memory_rsrc->allocate(nbytes, alignment);`
|
| 274 |
|
|
|
|
| 284 |
*Effects:* Equivalent to
|
| 285 |
`memory_rsrc->deallocate(p, nbytes, alignment)`.
|
| 286 |
|
| 287 |
``` cpp
|
| 288 |
template<class T>
|
| 289 |
+
T* allocate_object(size_t n = 1);
|
| 290 |
```
|
| 291 |
|
| 292 |
*Effects:* Allocates memory suitable for holding an array of `n` objects
|
| 293 |
of type `T`, as follows:
|
| 294 |
|
|
|
|
| 309 |
|
| 310 |
*Effects:* Equivalent to `deallocate_bytes(p, n*sizeof(T), alignof(T))`.
|
| 311 |
|
| 312 |
``` cpp
|
| 313 |
template<class T, class... CtorArgs>
|
| 314 |
+
T* new_object(CtorArgs&&... ctor_args);
|
| 315 |
```
|
| 316 |
|
| 317 |
*Effects:* Allocates and constructs an object of type `T`, as follows.
|
| 318 |
Equivalent to:
|
| 319 |
|
|
|
|
| 337 |
```
|
| 338 |
|
| 339 |
*Effects:* Equivalent to:
|
| 340 |
|
| 341 |
``` cpp
|
| 342 |
+
destroy(p);
|
| 343 |
deallocate_object(p);
|
| 344 |
```
|
| 345 |
|
| 346 |
``` cpp
|
| 347 |
template<class T, class... Args>
|
|
|
|
| 350 |
|
| 351 |
*Mandates:* Uses-allocator construction of `T` with allocator `*this`
|
| 352 |
(see [[allocator.uses.construction]]) and constructor arguments
|
| 353 |
`std::forward<Args>(args)...` is well-formed.
|
| 354 |
|
| 355 |
+
*Effects:* Constructs a `T` object in the storage whose address is
|
| 356 |
represented by `p` by uses-allocator construction with allocator `*this`
|
| 357 |
and constructor arguments `std::forward<Args>(args)...`.
|
| 358 |
|
| 359 |
*Throws:* Nothing unless the constructor for `T` throws.
|
| 360 |
|
| 361 |
+
``` cpp
|
| 362 |
+
template<class T>
|
| 363 |
+
void destroy(T* p);
|
| 364 |
+
```
|
| 365 |
+
|
| 366 |
+
*Effects:* Equivalent to `p->T̃()`.
|
| 367 |
+
|
| 368 |
``` cpp
|
| 369 |
polymorphic_allocator select_on_container_copy_construction() const;
|
| 370 |
```
|
| 371 |
|
| 372 |
*Returns:* `polymorphic_allocator()`.
|
|
|
|
| 425 |
pointer to `new_delete_resource()`.
|
| 426 |
|
| 427 |
*Returns:* The previous value of the default memory resource pointer.
|
| 428 |
|
| 429 |
*Remarks:* Calling the `set_default_resource` and `get_default_resource`
|
| 430 |
+
functions shall not incur a data race [[intro.races]]. A call to the
|
| 431 |
+
`set_default_resource` function synchronizes with subsequent calls to
|
| 432 |
+
the `set_default_resource` and `get_default_resource` functions.
|
| 433 |
|
| 434 |
``` cpp
|
| 435 |
memory_resource* get_default_resource() noexcept;
|
| 436 |
```
|
| 437 |
|
|
|
|
| 548 |
The maximum number of blocks that will be allocated at once from the
|
| 549 |
upstream memory resource [[mem.res.monotonic.buffer]] to replenish a
|
| 550 |
pool. If the value of `max_blocks_per_chunk` is zero or is greater than
|
| 551 |
an *implementation-defined* limit, that limit is used instead. The
|
| 552 |
implementation may choose to use a smaller value than is specified in
|
| 553 |
+
this member and may use different values for different pools.
|
| 554 |
|
| 555 |
``` cpp
|
| 556 |
size_t largest_required_pool_block;
|
| 557 |
```
|
| 558 |
|
|
|
|
| 560 |
pooling mechanism. Attempts to allocate a single block larger than this
|
| 561 |
threshold will be allocated directly from the upstream memory resource.
|
| 562 |
If `largest_required_pool_block` is zero or is greater than an
|
| 563 |
*implementation-defined* limit, that limit is used instead. The
|
| 564 |
implementation may choose a pass-through threshold larger than specified
|
| 565 |
+
in this member.
|
| 566 |
|
| 567 |
#### Constructors and destructors <a id="mem.res.pool.ctor">[[mem.res.pool.ctor]]</a>
|
| 568 |
|
| 569 |
``` cpp
|
| 570 |
synchronized_pool_resource(const pool_options& opts, memory_resource* upstream);
|
|
|
|
| 749 |
*Effects:* Calls `upstream_rsrc->deallocate()` as necessary to release
|
| 750 |
all allocated memory. Resets `current_buffer` and `next_buffer_size` to
|
| 751 |
their initial values at construction.
|
| 752 |
|
| 753 |
[*Note 1*: The memory is released back to `upstream_rsrc` even if some
|
| 754 |
+
blocks that were allocated from `*this` have not been deallocated from
|
| 755 |
+
`*this`. — *end note*]
|
| 756 |
|
| 757 |
``` cpp
|
| 758 |
memory_resource* upstream_resource() const;
|
| 759 |
```
|
| 760 |
|