tmp/tmp8kdpi9in/{from.md → to.md}
RENAMED
|
@@ -1,125 +1,141 @@
|
|
| 1 |
#### Array forms <a id="new.delete.array">[[new.delete.array]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
void* operator new[](std::size_t size);
|
|
|
|
| 5 |
```
|
| 6 |
|
| 7 |
-
*Effects:* The
|
| 8 |
called by the array form of a *new-expression* ([[expr.new]]) to
|
| 9 |
-
allocate `size` bytes of storage
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
*Replaceable:*
|
| 13 |
-
|
| 14 |
-
library.
|
| 15 |
|
| 16 |
-
*Required behavior:* Same as for
|
| 17 |
-
requirement is binding on
|
|
|
|
| 18 |
|
| 19 |
-
*Default behavior:* Returns `operator new(size)`
|
|
|
|
| 20 |
|
| 21 |
``` cpp
|
| 22 |
void* operator new[](std::size_t size, const std::nothrow_t&) noexcept;
|
|
|
|
| 23 |
```
|
| 24 |
|
| 25 |
-
*Effects:* Same as above, except that
|
| 26 |
version of a *new-expression* when a C++program prefers a null pointer
|
| 27 |
result as an error indication, instead of a `bad_alloc` exception.
|
| 28 |
|
| 29 |
-
*Replaceable:*
|
| 30 |
-
|
| 31 |
-
library.
|
| 32 |
|
| 33 |
*Required behavior:* Return a non-null pointer to suitably aligned
|
| 34 |
-
storage ([[basic.stc.dynamic]]), or return a null pointer.
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
*Default behavior:* Calls `operator new[](size)`
|
|
|
|
| 38 |
normally, returns the result of that call. Otherwise, returns a null
|
| 39 |
pointer.
|
| 40 |
|
| 41 |
``` cpp
|
| 42 |
void operator delete[](void* ptr) noexcept;
|
| 43 |
void operator delete[](void* ptr, std::size_t size) noexcept;
|
|
|
|
|
|
|
| 44 |
```
|
| 45 |
|
| 46 |
-
*Effects:* The
|
| 47 |
-
|
| 48 |
of a *delete-expression* to render the value of `ptr` invalid.
|
| 49 |
|
| 50 |
-
*Replaceable:*
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
`size` parameter) is defined, the program should also define
|
| 54 |
-
`void operator delete[](void* ptr, std::size_t size) noexcept`. If this
|
| 55 |
-
function with `size` parameter is defined, the program shall also define
|
| 56 |
-
the version without the `size` parameter. The default behavior below may
|
| 57 |
-
change in the future, which will require replacing both deallocation
|
| 58 |
-
functions when replacing the allocation function.
|
| 59 |
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
|
| 65 |
-
*
|
| 66 |
-
|
|
|
|
| 67 |
|
| 68 |
-
*
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
`operator delete[](void* ptr, std::size_t size)` to simply call
|
| 73 |
-
`operator delete[](
|
| 74 |
|
| 75 |
-
*
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
calls `operator delete[](ptr)`, and `operator delete[](void* ptr)` calls
|
| 81 |
-
`operator delete(ptr)`.
|
| 82 |
|
| 83 |
``` cpp
|
| 84 |
void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
|
| 85 |
-
void operator delete[](void* ptr, std::
|
| 86 |
```
|
| 87 |
|
| 88 |
-
*Effects:* The
|
| 89 |
-
|
| 90 |
implementation to render the value of `ptr` invalid when the constructor
|
| 91 |
invoked from a nothrow placement version of the array *new-expression*
|
| 92 |
throws an exception.
|
| 93 |
|
| 94 |
-
*Replaceable:*
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
both deallocation functions when replacing the allocation function.
|
| 104 |
|
| 105 |
*Requires:* If an implementation has strict pointer
|
| 106 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 107 |
safely-derived pointer.
|
| 108 |
|
| 109 |
-
*Requires:* If
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
-
*
|
| 113 |
-
`operator delete[](
|
| 114 |
-
may be changed to calls to
|
| 115 |
-
`operator delete[](void* ptr, const std::nothrow_t&)` without affecting
|
| 116 |
-
memory allocation. A conforming implementation is for
|
| 117 |
-
`operator delete[](void* ptr, std::size_t size, const std::nothrow_t&)`
|
| 118 |
-
to simply call `operator delete[](void* ptr, const std::nothrow_t&)`.
|
| 119 |
-
|
| 120 |
-
*Default behavior:*
|
| 121 |
-
`operator delete[](void* ptr, std::size_t size, const std::nothrow_t&)`
|
| 122 |
-
calls `operator delete[](ptr, std::nothrow)`, and
|
| 123 |
-
`operator delete[](void* ptr, const std::nothrow_t&)` calls
|
| 124 |
-
`operator delete[](ptr)`.
|
| 125 |
|
|
|
|
| 1 |
#### Array forms <a id="new.delete.array">[[new.delete.array]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
void* operator new[](std::size_t size);
|
| 5 |
+
void* operator new[](std::size_t size, std::align_val_t alignment);
|
| 6 |
```
|
| 7 |
|
| 8 |
+
*Effects:* The allocation functions ([[basic.stc.dynamic.allocation]])
|
| 9 |
called by the array form of a *new-expression* ([[expr.new]]) to
|
| 10 |
+
allocate `size` bytes of storage. The second form is called for a type
|
| 11 |
+
with new-extended alignment, and allocates storage with the specified
|
| 12 |
+
alignment. The first form is called otherwise, and allocates storage
|
| 13 |
+
suitably aligned to represent any array object of that size or smaller,
|
| 14 |
+
provided the object’s type does not have new-extended alignment. [^33]
|
| 15 |
|
| 16 |
+
*Replaceable:* A C++program may define functions with either of these
|
| 17 |
+
function signatures, and thereby displace the default versions defined
|
| 18 |
+
by the C++standard library.
|
| 19 |
|
| 20 |
+
*Required behavior:* Same as for the corresponding single-object forms.
|
| 21 |
+
This requirement is binding on any replacement versions of these
|
| 22 |
+
functions.
|
| 23 |
|
| 24 |
+
*Default behavior:* Returns `operator new(size)`, or
|
| 25 |
+
`operator new(size, alignment)`, respectively.
|
| 26 |
|
| 27 |
``` cpp
|
| 28 |
void* operator new[](std::size_t size, const std::nothrow_t&) noexcept;
|
| 29 |
+
void* operator new[](std::size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept;
|
| 30 |
```
|
| 31 |
|
| 32 |
+
*Effects:* Same as above, except that these are called by a placement
|
| 33 |
version of a *new-expression* when a C++program prefers a null pointer
|
| 34 |
result as an error indication, instead of a `bad_alloc` exception.
|
| 35 |
|
| 36 |
+
*Replaceable:* A C++program may define functions with either of these
|
| 37 |
+
function signatures, and thereby displace the default versions defined
|
| 38 |
+
by the C++standard library.
|
| 39 |
|
| 40 |
*Required behavior:* Return a non-null pointer to suitably aligned
|
| 41 |
+
storage ([[basic.stc.dynamic]]), or else return a null pointer. Each of
|
| 42 |
+
these nothrow versions of `operator new[]` returns a pointer obtained as
|
| 43 |
+
if acquired from the (possibly replaced) corresponding non-placement
|
| 44 |
+
function. This requirement is binding on any replacement versions of
|
| 45 |
+
these functions.
|
| 46 |
|
| 47 |
+
*Default behavior:* Calls `operator new[](size)`, or
|
| 48 |
+
`operator new[](size, alignment)`, respectively. If the call returns
|
| 49 |
normally, returns the result of that call. Otherwise, returns a null
|
| 50 |
pointer.
|
| 51 |
|
| 52 |
``` cpp
|
| 53 |
void operator delete[](void* ptr) noexcept;
|
| 54 |
void operator delete[](void* ptr, std::size_t size) noexcept;
|
| 55 |
+
void operator delete[](void* ptr, std::align_val_t alignment) noexcept;
|
| 56 |
+
void operator delete[](void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
|
| 57 |
```
|
| 58 |
|
| 59 |
+
*Effects:* The deallocation
|
| 60 |
+
functions ([[basic.stc.dynamic.deallocation]]) called by the array form
|
| 61 |
of a *delete-expression* to render the value of `ptr` invalid.
|
| 62 |
|
| 63 |
+
*Replaceable:* A C++program may define functions with any of these
|
| 64 |
+
function signatures, and thereby displace the default versions defined
|
| 65 |
+
by the C++standard library.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
+
If a function without a `size` parameter is defined, the program should
|
| 68 |
+
also define the corresponding function with a `size` parameter. If a
|
| 69 |
+
function with a `size` parameter is defined, the program shall also
|
| 70 |
+
define the corresponding version without the `size` parameter.
|
| 71 |
|
| 72 |
+
[*Note 1*: The default behavior below may change in the future, which
|
| 73 |
+
will require replacing both deallocation functions when replacing the
|
| 74 |
+
allocation function. — *end note*]
|
| 75 |
|
| 76 |
+
*Requires:* `ptr` shall be a null pointer or its value shall represent
|
| 77 |
+
the address of a block of memory allocated by an earlier call to a
|
| 78 |
+
(possibly replaced) `operator new[](std::size_t)` or
|
| 79 |
+
`operator new[](std::size_t, std::align_val_t)` which has not been
|
| 80 |
+
invalidated by an intervening call to `operator delete[]`.
|
| 81 |
+
|
| 82 |
+
*Requires:* If an implementation has strict pointer
|
| 83 |
+
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 84 |
+
safely-derived pointer.
|
| 85 |
+
|
| 86 |
+
*Requires:* If the `alignment` parameter is not present, `ptr` shall
|
| 87 |
+
have been returned by an allocation function without an `alignment`
|
| 88 |
+
parameter. If present, the `alignment` argument shall equal the
|
| 89 |
+
`alignment` argument passed to the allocation function that returned
|
| 90 |
+
`ptr`. If present, the `size` argument shall equal the `size` argument
|
| 91 |
+
passed to the allocation function that returned `ptr`.
|
| 92 |
+
|
| 93 |
+
*Required behavior:* A call to an `operator delete[]` with a `size`
|
| 94 |
+
parameter may be changed to a call to the corresponding
|
| 95 |
+
`operator delete[]` without a `size` parameter, without affecting memory
|
| 96 |
+
allocation.
|
| 97 |
+
|
| 98 |
+
[*Note 2*: A conforming implementation is for
|
| 99 |
`operator delete[](void* ptr, std::size_t size)` to simply call
|
| 100 |
+
`operator delete[](ptr)`. — *end note*]
|
| 101 |
|
| 102 |
+
*Default behavior:* The functions that have a `size` parameter forward
|
| 103 |
+
their other parameters to the corresponding function without a `size`
|
| 104 |
+
parameter. The functions that do not have a `size` parameter forward
|
| 105 |
+
their parameters to the corresponding `operator delete` (single-object)
|
| 106 |
+
function.
|
|
|
|
|
|
|
| 107 |
|
| 108 |
``` cpp
|
| 109 |
void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
|
| 110 |
+
void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
|
| 111 |
```
|
| 112 |
|
| 113 |
+
*Effects:* The deallocation
|
| 114 |
+
functions ([[basic.stc.dynamic.deallocation]]) called by the
|
| 115 |
implementation to render the value of `ptr` invalid when the constructor
|
| 116 |
invoked from a nothrow placement version of the array *new-expression*
|
| 117 |
throws an exception.
|
| 118 |
|
| 119 |
+
*Replaceable:* A C++program may define functions with either of these
|
| 120 |
+
function signatures, and thereby displace the default versions defined
|
| 121 |
+
by the C++standard library.
|
| 122 |
+
|
| 123 |
+
*Requires:* `ptr` shall be a null pointer or its value shall represent
|
| 124 |
+
the address of a block of memory allocated by an earlier call to a
|
| 125 |
+
(possibly replaced) `operator new[](std::size_t)` or
|
| 126 |
+
`operator new[](std::size_t, std::align_val_t)` which has not been
|
| 127 |
+
invalidated by an intervening call to `operator delete[]`.
|
|
|
|
| 128 |
|
| 129 |
*Requires:* If an implementation has strict pointer
|
| 130 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 131 |
safely-derived pointer.
|
| 132 |
|
| 133 |
+
*Requires:* If the `alignment` parameter is not present, `ptr` shall
|
| 134 |
+
have been returned by an allocation function without an `alignment`
|
| 135 |
+
parameter. If present, the `alignment` argument shall equal the
|
| 136 |
+
`alignment` argument passed to the allocation function that returned
|
| 137 |
+
`ptr`.
|
| 138 |
|
| 139 |
+
*Default behavior:* Calls `operator delete[](ptr)`, or
|
| 140 |
+
`operator delete[](ptr, alignment)`, respectively.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
|