tmp/tmpm4vst13c/{from.md → to.md}
RENAMED
|
@@ -6,26 +6,37 @@ Except where otherwise specified, the provisions of
|
|
| 6 |
[[basic.stc.dynamic]] apply to the library versions of `operator new`
|
| 7 |
and `operator
|
| 8 |
delete`. If the value of an alignment argument passed to any of these
|
| 9 |
functions is not a valid alignment value, the behavior is undefined.
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
#### Single-object forms <a id="new.delete.single">[[new.delete.single]]</a>
|
| 12 |
|
| 13 |
``` cpp
|
| 14 |
-
|
| 15 |
-
|
| 16 |
```
|
| 17 |
|
| 18 |
*Effects:* The allocation functions [[basic.stc.dynamic.allocation]]
|
| 19 |
called by a *new-expression*[[expr.new]] to allocate `size` bytes of
|
| 20 |
storage. The second form is called for a type with new-extended
|
| 21 |
alignment, and the first form is called otherwise.
|
| 22 |
|
| 23 |
-
*Replaceable:* A C++ program may define functions with either of these
|
| 24 |
-
function signatures, and thereby displace the default versions defined
|
| 25 |
-
by the C++ standard library.
|
| 26 |
-
|
| 27 |
*Required behavior:* Return a non-null pointer to suitably aligned
|
| 28 |
storage [[basic.stc.dynamic]], or else throw a `bad_alloc` exception.
|
| 29 |
This requirement is binding on any replacement versions of these
|
| 30 |
functions.
|
| 31 |
|
|
@@ -42,24 +53,21 @@ functions.
|
|
| 42 |
function [[new.handler]]. If the called function returns, the loop
|
| 43 |
repeats.
|
| 44 |
- The loop terminates when an attempt to allocate the requested storage
|
| 45 |
is successful or when a called `new_handler` function does not return.
|
| 46 |
|
|
|
|
|
|
|
| 47 |
``` cpp
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
const std::nothrow_t&) noexcept;
|
| 51 |
```
|
| 52 |
|
| 53 |
*Effects:* Same as above, except that these are called by a placement
|
| 54 |
version of a *new-expression* when a C++ program prefers a null pointer
|
| 55 |
result as an error indication, instead of a `bad_alloc` exception.
|
| 56 |
|
| 57 |
-
*Replaceable:* A C++ program may define functions with either of these
|
| 58 |
-
function signatures, and thereby displace the default versions defined
|
| 59 |
-
by the C++ standard library.
|
| 60 |
-
|
| 61 |
*Required behavior:* Return a non-null pointer to suitably aligned
|
| 62 |
storage [[basic.stc.dynamic]], or else return a null pointer. Each of
|
| 63 |
these nothrow versions of `operator new` returns a pointer obtained as
|
| 64 |
if acquired from the (possibly replaced) corresponding non-placement
|
| 65 |
function. This requirement is binding on any replacement versions of
|
|
@@ -77,10 +85,12 @@ T* p1 = new T; // throws bad_alloc if it fails
|
|
| 77 |
T* p2 = new(nothrow) T; // returns nullptr if it fails
|
| 78 |
```
|
| 79 |
|
| 80 |
— *end example*]
|
| 81 |
|
|
|
|
|
|
|
| 82 |
``` cpp
|
| 83 |
void operator delete(void* ptr) noexcept;
|
| 84 |
void operator delete(void* ptr, std::size_t size) noexcept;
|
| 85 |
void operator delete(void* ptr, std::align_val_t alignment) noexcept;
|
| 86 |
void operator delete(void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
|
|
@@ -101,46 +111,43 @@ returned `ptr`.
|
|
| 101 |
|
| 102 |
*Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
|
| 103 |
called by a *delete-expression*[[expr.delete]] to render the value of
|
| 104 |
`ptr` invalid.
|
| 105 |
|
| 106 |
-
*Replaceable:* A C++ program may define functions with any of these
|
| 107 |
-
function signatures, and thereby displace the default versions defined
|
| 108 |
-
by the C++ standard library.
|
| 109 |
-
|
| 110 |
-
If a function without a `size` parameter is defined, the program should
|
| 111 |
-
also define the corresponding function with a `size` parameter. If a
|
| 112 |
-
function with a `size` parameter is defined, the program shall also
|
| 113 |
-
define the corresponding version without the `size` parameter.
|
| 114 |
-
|
| 115 |
-
[*Note 1*: The default behavior below might change in the future, which
|
| 116 |
-
will require replacing both deallocation functions when replacing the
|
| 117 |
-
allocation function. — *end note*]
|
| 118 |
-
|
| 119 |
*Required behavior:* A call to an `operator delete` with a `size`
|
| 120 |
parameter may be changed to a call to the corresponding
|
| 121 |
`operator delete` without a `size` parameter, without affecting memory
|
| 122 |
allocation.
|
| 123 |
|
| 124 |
-
[*Note
|
| 125 |
`operator delete(void* ptr, std::size_t size)` to simply call
|
| 126 |
`operator delete(ptr)`. — *end note*]
|
| 127 |
|
| 128 |
*Default behavior:* The functions that have a `size` parameter forward
|
| 129 |
their other parameters to the corresponding function without a `size`
|
| 130 |
parameter.
|
| 131 |
|
| 132 |
-
[*Note
|
| 133 |
paragraph. — *end note*]
|
| 134 |
|
| 135 |
*Default behavior:* If `ptr` is null, does nothing. Otherwise, reclaims
|
| 136 |
the storage allocated by the earlier call to `operator new`.
|
| 137 |
|
| 138 |
*Remarks:* It is unspecified under what conditions part or all of such
|
| 139 |
reclaimed storage will be allocated by subsequent calls to
|
| 140 |
`operator new` or any of `aligned_alloc`, `calloc`, `malloc`, or
|
| 141 |
-
`realloc`, declared in `<cstdlib>`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
``` cpp
|
| 144 |
void operator delete(void* ptr, const std::nothrow_t&) noexcept;
|
| 145 |
void operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
|
| 146 |
```
|
|
@@ -159,54 +166,45 @@ allocation function that returned `ptr`.
|
|
| 159 |
*Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
|
| 160 |
called by the implementation to render the value of `ptr` invalid when
|
| 161 |
the constructor invoked from a nothrow placement version of the
|
| 162 |
*new-expression* throws an exception.
|
| 163 |
|
| 164 |
-
*Replaceable:* A C++ program may define functions with either of these
|
| 165 |
-
function signatures, and thereby displace the default versions defined
|
| 166 |
-
by the C++ standard library.
|
| 167 |
-
|
| 168 |
*Default behavior:* Calls `operator delete(ptr)`, or
|
| 169 |
`operator delete(ptr, alignment)`, respectively.
|
| 170 |
|
|
|
|
|
|
|
| 171 |
#### Array forms <a id="new.delete.array">[[new.delete.array]]</a>
|
| 172 |
|
| 173 |
``` cpp
|
| 174 |
-
|
| 175 |
-
|
| 176 |
```
|
| 177 |
|
| 178 |
*Effects:* The allocation functions [[basic.stc.dynamic.allocation]]
|
| 179 |
called by the array form of a *new-expression*[[expr.new]] to allocate
|
| 180 |
`size` bytes of storage. The second form is called for a type with
|
| 181 |
new-extended alignment, and the first form is called otherwise.[^31]
|
| 182 |
|
| 183 |
-
*Replaceable:* A C++ program may define functions with either of these
|
| 184 |
-
function signatures, and thereby displace the default versions defined
|
| 185 |
-
by the C++ standard library.
|
| 186 |
-
|
| 187 |
*Required behavior:* Same as for the corresponding single-object forms.
|
| 188 |
This requirement is binding on any replacement versions of these
|
| 189 |
functions.
|
| 190 |
|
| 191 |
*Default behavior:* Returns `operator new(size)`, or
|
| 192 |
`operator new(size, alignment)`, respectively.
|
| 193 |
|
|
|
|
|
|
|
| 194 |
``` cpp
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
const std::nothrow_t&) noexcept;
|
| 198 |
```
|
| 199 |
|
| 200 |
*Effects:* Same as above, except that these are called by a placement
|
| 201 |
version of a *new-expression* when a C++ program prefers a null pointer
|
| 202 |
result as an error indication, instead of a `bad_alloc` exception.
|
| 203 |
|
| 204 |
-
*Replaceable:* A C++ program may define functions with either of these
|
| 205 |
-
function signatures, and thereby displace the default versions defined
|
| 206 |
-
by the C++ standard library.
|
| 207 |
-
|
| 208 |
*Required behavior:* Return a non-null pointer to suitably aligned
|
| 209 |
storage [[basic.stc.dynamic]], or else return a null pointer. Each of
|
| 210 |
these nothrow versions of `operator new[]` returns a pointer obtained as
|
| 211 |
if acquired from the (possibly replaced) corresponding non-placement
|
| 212 |
function. This requirement is binding on any replacement versions of
|
|
@@ -215,10 +213,12 @@ these functions.
|
|
| 215 |
*Default behavior:* Calls `operator new[](size)`, or
|
| 216 |
`operator new[](size, alignment)`, respectively. If the call returns
|
| 217 |
normally, returns the result of that call. Otherwise, returns a null
|
| 218 |
pointer.
|
| 219 |
|
|
|
|
|
|
|
| 220 |
``` cpp
|
| 221 |
void operator delete[](void* ptr) noexcept;
|
| 222 |
void operator delete[](void* ptr, std::size_t size) noexcept;
|
| 223 |
void operator delete[](void* ptr, std::align_val_t alignment) noexcept;
|
| 224 |
void operator delete[](void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
|
|
@@ -239,38 +239,36 @@ returned `ptr`.
|
|
| 239 |
|
| 240 |
*Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
|
| 241 |
called by the array form of a *delete-expression* to render the value of
|
| 242 |
`ptr` invalid.
|
| 243 |
|
| 244 |
-
*Replaceable:* A C++ program may define functions with any of these
|
| 245 |
-
function signatures, and thereby displace the default versions defined
|
| 246 |
-
by the C++ standard library.
|
| 247 |
-
|
| 248 |
-
If a function without a `size` parameter is defined, the program should
|
| 249 |
-
also define the corresponding function with a `size` parameter. If a
|
| 250 |
-
function with a `size` parameter is defined, the program shall also
|
| 251 |
-
define the corresponding version without the `size` parameter.
|
| 252 |
-
|
| 253 |
-
[*Note 1*: The default behavior below might change in the future, which
|
| 254 |
-
will require replacing both deallocation functions when replacing the
|
| 255 |
-
allocation function. — *end note*]
|
| 256 |
-
|
| 257 |
*Required behavior:* A call to an `operator delete[]` with a `size`
|
| 258 |
parameter may be changed to a call to the corresponding
|
| 259 |
`operator delete[]` without a `size` parameter, without affecting memory
|
| 260 |
allocation.
|
| 261 |
|
| 262 |
-
[*Note
|
| 263 |
`operator delete[](void* ptr, std::size_t size)` to simply call
|
| 264 |
`operator delete[](ptr)`. — *end note*]
|
| 265 |
|
| 266 |
*Default behavior:* The functions that have a `size` parameter forward
|
| 267 |
their other parameters to the corresponding function without a `size`
|
| 268 |
parameter. The functions that do not have a `size` parameter forward
|
| 269 |
their parameters to the corresponding `operator delete` (single-object)
|
| 270 |
function.
|
| 271 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 272 |
``` cpp
|
| 273 |
void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
|
| 274 |
void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
|
| 275 |
```
|
| 276 |
|
|
@@ -288,26 +286,24 @@ allocation function that returned `ptr`.
|
|
| 288 |
*Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
|
| 289 |
called by the implementation to render the value of `ptr` invalid when
|
| 290 |
the constructor invoked from a nothrow placement version of the array
|
| 291 |
*new-expression* throws an exception.
|
| 292 |
|
| 293 |
-
*Replaceable:* A C++ program may define functions with either of these
|
| 294 |
-
function signatures, and thereby displace the default versions defined
|
| 295 |
-
by the C++ standard library.
|
| 296 |
-
|
| 297 |
*Default behavior:* Calls `operator delete[](ptr)`, or
|
| 298 |
`operator delete[](ptr, alignment)`, respectively.
|
| 299 |
|
|
|
|
|
|
|
| 300 |
#### Non-allocating forms <a id="new.delete.placement">[[new.delete.placement]]</a>
|
| 301 |
|
| 302 |
These functions are reserved; a C++ program may not define functions
|
| 303 |
that displace the versions in the C++ standard library [[constraints]].
|
| 304 |
The provisions of [[basic.stc.dynamic]] do not apply to these reserved
|
| 305 |
placement forms of `operator new` and `operator delete`.
|
| 306 |
|
| 307 |
``` cpp
|
| 308 |
-
|
| 309 |
```
|
| 310 |
|
| 311 |
*Returns:* `ptr`.
|
| 312 |
|
| 313 |
*Remarks:* Intentionally performs no other action.
|
|
@@ -322,11 +318,11 @@ Something* p = new (place) Something();
|
|
| 322 |
```
|
| 323 |
|
| 324 |
— *end example*]
|
| 325 |
|
| 326 |
``` cpp
|
| 327 |
-
|
| 328 |
```
|
| 329 |
|
| 330 |
*Returns:* `ptr`.
|
| 331 |
|
| 332 |
*Remarks:* Intentionally performs no other action.
|
|
|
|
| 6 |
[[basic.stc.dynamic]] apply to the library versions of `operator new`
|
| 7 |
and `operator
|
| 8 |
delete`. If the value of an alignment argument passed to any of these
|
| 9 |
functions is not a valid alignment value, the behavior is undefined.
|
| 10 |
|
| 11 |
+
On freestanding implementations, it is *implementation-defined* whether
|
| 12 |
+
the default versions of the replaceable global allocation functions
|
| 13 |
+
satisfy the required behaviors described in [[new.delete.single]] and
|
| 14 |
+
[[new.delete.array]].
|
| 15 |
+
|
| 16 |
+
[*Note 1*: A freestanding implementation’s default versions of the
|
| 17 |
+
replaceable global allocation functions can cause undefined behavior
|
| 18 |
+
when invoked. During constant evaluation, the behaviors of those default
|
| 19 |
+
versions are irrelevant, as those calls are omitted
|
| 20 |
+
[[expr.new]]. — *end note*]
|
| 21 |
+
|
| 22 |
+
*Recommended practice:* If any of the default versions of the
|
| 23 |
+
replaceable global allocation functions meet the requirements of a
|
| 24 |
+
hosted implementation, they all should.
|
| 25 |
+
|
| 26 |
#### Single-object forms <a id="new.delete.single">[[new.delete.single]]</a>
|
| 27 |
|
| 28 |
``` cpp
|
| 29 |
+
void* operator new(std::size_t size);
|
| 30 |
+
void* operator new(std::size_t size, std::align_val_t alignment);
|
| 31 |
```
|
| 32 |
|
| 33 |
*Effects:* The allocation functions [[basic.stc.dynamic.allocation]]
|
| 34 |
called by a *new-expression*[[expr.new]] to allocate `size` bytes of
|
| 35 |
storage. The second form is called for a type with new-extended
|
| 36 |
alignment, and the first form is called otherwise.
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
*Required behavior:* Return a non-null pointer to suitably aligned
|
| 39 |
storage [[basic.stc.dynamic]], or else throw a `bad_alloc` exception.
|
| 40 |
This requirement is binding on any replacement versions of these
|
| 41 |
functions.
|
| 42 |
|
|
|
|
| 53 |
function [[new.handler]]. If the called function returns, the loop
|
| 54 |
repeats.
|
| 55 |
- The loop terminates when an attempt to allocate the requested storage
|
| 56 |
is successful or when a called `new_handler` function does not return.
|
| 57 |
|
| 58 |
+
*Remarks:* This function is replaceable [[term.replaceable.function]].
|
| 59 |
+
|
| 60 |
``` cpp
|
| 61 |
+
void* operator new(std::size_t size, const std::nothrow_t&) noexcept;
|
| 62 |
+
void* operator new(std::size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept;
|
|
|
|
| 63 |
```
|
| 64 |
|
| 65 |
*Effects:* Same as above, except that these are called by a placement
|
| 66 |
version of a *new-expression* when a C++ program prefers a null pointer
|
| 67 |
result as an error indication, instead of a `bad_alloc` exception.
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
*Required behavior:* Return a non-null pointer to suitably aligned
|
| 70 |
storage [[basic.stc.dynamic]], or else return a null pointer. Each of
|
| 71 |
these nothrow versions of `operator new` returns a pointer obtained as
|
| 72 |
if acquired from the (possibly replaced) corresponding non-placement
|
| 73 |
function. This requirement is binding on any replacement versions of
|
|
|
|
| 85 |
T* p2 = new(nothrow) T; // returns nullptr if it fails
|
| 86 |
```
|
| 87 |
|
| 88 |
— *end example*]
|
| 89 |
|
| 90 |
+
*Remarks:* This function is replaceable [[term.replaceable.function]].
|
| 91 |
+
|
| 92 |
``` cpp
|
| 93 |
void operator delete(void* ptr) noexcept;
|
| 94 |
void operator delete(void* ptr, std::size_t size) noexcept;
|
| 95 |
void operator delete(void* ptr, std::align_val_t alignment) noexcept;
|
| 96 |
void operator delete(void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
|
|
|
|
| 111 |
|
| 112 |
*Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
|
| 113 |
called by a *delete-expression*[[expr.delete]] to render the value of
|
| 114 |
`ptr` invalid.
|
| 115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
*Required behavior:* A call to an `operator delete` with a `size`
|
| 117 |
parameter may be changed to a call to the corresponding
|
| 118 |
`operator delete` without a `size` parameter, without affecting memory
|
| 119 |
allocation.
|
| 120 |
|
| 121 |
+
[*Note 1*: A conforming implementation is for
|
| 122 |
`operator delete(void* ptr, std::size_t size)` to simply call
|
| 123 |
`operator delete(ptr)`. — *end note*]
|
| 124 |
|
| 125 |
*Default behavior:* The functions that have a `size` parameter forward
|
| 126 |
their other parameters to the corresponding function without a `size`
|
| 127 |
parameter.
|
| 128 |
|
| 129 |
+
[*Note 2*: See the note in the below *Remarks:*
|
| 130 |
paragraph. — *end note*]
|
| 131 |
|
| 132 |
*Default behavior:* If `ptr` is null, does nothing. Otherwise, reclaims
|
| 133 |
the storage allocated by the earlier call to `operator new`.
|
| 134 |
|
| 135 |
*Remarks:* It is unspecified under what conditions part or all of such
|
| 136 |
reclaimed storage will be allocated by subsequent calls to
|
| 137 |
`operator new` or any of `aligned_alloc`, `calloc`, `malloc`, or
|
| 138 |
+
`realloc`, declared in `<cstdlib>`. This function is
|
| 139 |
+
replaceable [[term.replaceable.function]]. If a replacement function
|
| 140 |
+
without a `size` parameter is defined by the program, the program should
|
| 141 |
+
also define the corresponding function with a `size` parameter. If a
|
| 142 |
+
replacement function with a `size` parameter is defined by the program,
|
| 143 |
+
the program shall also define the corresponding version without the
|
| 144 |
+
`size` parameter.
|
| 145 |
+
|
| 146 |
+
[*Note 3*: The default behavior above might change in the future, which
|
| 147 |
+
will require replacing both deallocation functions when replacing the
|
| 148 |
+
allocation function. — *end note*]
|
| 149 |
|
| 150 |
``` cpp
|
| 151 |
void operator delete(void* ptr, const std::nothrow_t&) noexcept;
|
| 152 |
void operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
|
| 153 |
```
|
|
|
|
| 166 |
*Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
|
| 167 |
called by the implementation to render the value of `ptr` invalid when
|
| 168 |
the constructor invoked from a nothrow placement version of the
|
| 169 |
*new-expression* throws an exception.
|
| 170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
*Default behavior:* Calls `operator delete(ptr)`, or
|
| 172 |
`operator delete(ptr, alignment)`, respectively.
|
| 173 |
|
| 174 |
+
*Remarks:* This function is replaceable [[term.replaceable.function]].
|
| 175 |
+
|
| 176 |
#### Array forms <a id="new.delete.array">[[new.delete.array]]</a>
|
| 177 |
|
| 178 |
``` cpp
|
| 179 |
+
void* operator new[](std::size_t size);
|
| 180 |
+
void* operator new[](std::size_t size, std::align_val_t alignment);
|
| 181 |
```
|
| 182 |
|
| 183 |
*Effects:* The allocation functions [[basic.stc.dynamic.allocation]]
|
| 184 |
called by the array form of a *new-expression*[[expr.new]] to allocate
|
| 185 |
`size` bytes of storage. The second form is called for a type with
|
| 186 |
new-extended alignment, and the first form is called otherwise.[^31]
|
| 187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
*Required behavior:* Same as for the corresponding single-object forms.
|
| 189 |
This requirement is binding on any replacement versions of these
|
| 190 |
functions.
|
| 191 |
|
| 192 |
*Default behavior:* Returns `operator new(size)`, or
|
| 193 |
`operator new(size, alignment)`, respectively.
|
| 194 |
|
| 195 |
+
*Remarks:* This function is replaceable [[term.replaceable.function]].
|
| 196 |
+
|
| 197 |
``` cpp
|
| 198 |
+
void* operator new[](std::size_t size, const std::nothrow_t&) noexcept;
|
| 199 |
+
void* operator new[](std::size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept;
|
|
|
|
| 200 |
```
|
| 201 |
|
| 202 |
*Effects:* Same as above, except that these are called by a placement
|
| 203 |
version of a *new-expression* when a C++ program prefers a null pointer
|
| 204 |
result as an error indication, instead of a `bad_alloc` exception.
|
| 205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
*Required behavior:* Return a non-null pointer to suitably aligned
|
| 207 |
storage [[basic.stc.dynamic]], or else return a null pointer. Each of
|
| 208 |
these nothrow versions of `operator new[]` returns a pointer obtained as
|
| 209 |
if acquired from the (possibly replaced) corresponding non-placement
|
| 210 |
function. This requirement is binding on any replacement versions of
|
|
|
|
| 213 |
*Default behavior:* Calls `operator new[](size)`, or
|
| 214 |
`operator new[](size, alignment)`, respectively. If the call returns
|
| 215 |
normally, returns the result of that call. Otherwise, returns a null
|
| 216 |
pointer.
|
| 217 |
|
| 218 |
+
*Remarks:* This function is replaceable [[term.replaceable.function]].
|
| 219 |
+
|
| 220 |
``` cpp
|
| 221 |
void operator delete[](void* ptr) noexcept;
|
| 222 |
void operator delete[](void* ptr, std::size_t size) noexcept;
|
| 223 |
void operator delete[](void* ptr, std::align_val_t alignment) noexcept;
|
| 224 |
void operator delete[](void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
|
|
|
|
| 239 |
|
| 240 |
*Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
|
| 241 |
called by the array form of a *delete-expression* to render the value of
|
| 242 |
`ptr` invalid.
|
| 243 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 244 |
*Required behavior:* A call to an `operator delete[]` with a `size`
|
| 245 |
parameter may be changed to a call to the corresponding
|
| 246 |
`operator delete[]` without a `size` parameter, without affecting memory
|
| 247 |
allocation.
|
| 248 |
|
| 249 |
+
[*Note 1*: A conforming implementation is for
|
| 250 |
`operator delete[](void* ptr, std::size_t size)` to simply call
|
| 251 |
`operator delete[](ptr)`. — *end note*]
|
| 252 |
|
| 253 |
*Default behavior:* The functions that have a `size` parameter forward
|
| 254 |
their other parameters to the corresponding function without a `size`
|
| 255 |
parameter. The functions that do not have a `size` parameter forward
|
| 256 |
their parameters to the corresponding `operator delete` (single-object)
|
| 257 |
function.
|
| 258 |
|
| 259 |
+
*Remarks:* This function is replaceable [[term.replaceable.function]].
|
| 260 |
+
If a replacement function without a `size` parameter is defined by the
|
| 261 |
+
program, the program should also define the corresponding function with
|
| 262 |
+
a `size` parameter. If a replacement function with a `size` parameter is
|
| 263 |
+
defined by the program, the program shall also define the corresponding
|
| 264 |
+
version without the `size` parameter.
|
| 265 |
+
|
| 266 |
+
[*Note 2*: The default behavior above might change in the future, which
|
| 267 |
+
will require replacing both deallocation functions when replacing the
|
| 268 |
+
allocation function. — *end note*]
|
| 269 |
+
|
| 270 |
``` cpp
|
| 271 |
void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
|
| 272 |
void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
|
| 273 |
```
|
| 274 |
|
|
|
|
| 286 |
*Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
|
| 287 |
called by the implementation to render the value of `ptr` invalid when
|
| 288 |
the constructor invoked from a nothrow placement version of the array
|
| 289 |
*new-expression* throws an exception.
|
| 290 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 291 |
*Default behavior:* Calls `operator delete[](ptr)`, or
|
| 292 |
`operator delete[](ptr, alignment)`, respectively.
|
| 293 |
|
| 294 |
+
*Remarks:* This function is replaceable [[term.replaceable.function]].
|
| 295 |
+
|
| 296 |
#### Non-allocating forms <a id="new.delete.placement">[[new.delete.placement]]</a>
|
| 297 |
|
| 298 |
These functions are reserved; a C++ program may not define functions
|
| 299 |
that displace the versions in the C++ standard library [[constraints]].
|
| 300 |
The provisions of [[basic.stc.dynamic]] do not apply to these reserved
|
| 301 |
placement forms of `operator new` and `operator delete`.
|
| 302 |
|
| 303 |
``` cpp
|
| 304 |
+
constexpr void* operator new(std::size_t size, void* ptr) noexcept;
|
| 305 |
```
|
| 306 |
|
| 307 |
*Returns:* `ptr`.
|
| 308 |
|
| 309 |
*Remarks:* Intentionally performs no other action.
|
|
|
|
| 318 |
```
|
| 319 |
|
| 320 |
— *end example*]
|
| 321 |
|
| 322 |
``` cpp
|
| 323 |
+
constexpr void* operator new[](std::size_t size, void* ptr) noexcept;
|
| 324 |
```
|
| 325 |
|
| 326 |
*Returns:* `ptr`.
|
| 327 |
|
| 328 |
*Remarks:* Intentionally performs no other action.
|