- tmp/tmpqowksuyj/{from.md → to.md} +111 -28
tmp/tmpqowksuyj/{from.md → to.md}
RENAMED
|
@@ -60,24 +60,31 @@ is binding on a replacement version of this function.
|
|
| 60 |
normally, returns the result of that call. Otherwise, returns a null
|
| 61 |
pointer.
|
| 62 |
|
| 63 |
``` cpp
|
| 64 |
T* p1 = new T; // throws bad_alloc if it fails
|
| 65 |
-
T* p2 = new(nothrow) T; // returns
|
| 66 |
```
|
| 67 |
|
| 68 |
``` cpp
|
| 69 |
void operator delete(void* ptr) noexcept;
|
|
|
|
| 70 |
```
|
| 71 |
|
| 72 |
*Effects:* The *deallocation
|
| 73 |
function* ([[basic.stc.dynamic.deallocation]]) called by a
|
| 74 |
*delete-expression* to render the value of `ptr` invalid.
|
| 75 |
|
| 76 |
-
*Replaceable:* a C++program may define a function with
|
| 77 |
-
|
| 78 |
-
library.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
*Requires:* *ptr* shall be a null pointer or its value shall be a value
|
| 81 |
returned by an earlier call to the (possibly replaced)
|
| 82 |
`operator new(std::size_t)` or
|
| 83 |
`operator new(std::size_t,const std::nothrow_t&)` which has not been
|
|
@@ -85,37 +92,75 @@ invalidated by an intervening call to `operator delete(void*)`.
|
|
| 85 |
|
| 86 |
*Requires:* If an implementation has strict pointer
|
| 87 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 88 |
safely-derived pointer.
|
| 89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
*Default behavior:* If `ptr` is null, does nothing. Otherwise, reclaims
|
| 91 |
the storage allocated by the earlier call to `operator new`.
|
| 92 |
|
| 93 |
*Remarks:* It is unspecified under what conditions part or all of such
|
| 94 |
reclaimed storage will be allocated by subsequent calls to
|
| 95 |
`operator new` or any of `calloc`, `malloc`, or `realloc`, declared in
|
| 96 |
`<cstdlib>`.
|
| 97 |
|
| 98 |
``` cpp
|
| 99 |
void operator delete(void* ptr, const std::nothrow_t&) noexcept;
|
|
|
|
| 100 |
```
|
| 101 |
|
| 102 |
*Effects:* The *deallocation
|
| 103 |
function* ([[basic.stc.dynamic.deallocation]]) called by the
|
| 104 |
implementation to render the value of `ptr` invalid when the constructor
|
| 105 |
invoked from a nothrow placement version of the *new-expression* throws
|
| 106 |
an exception.
|
| 107 |
|
| 108 |
-
*Replaceable:* a C++program may define a function with
|
| 109 |
-
|
| 110 |
-
library.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
*Requires:* If an implementation has strict pointer
|
| 113 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 114 |
safely-derived pointer.
|
| 115 |
|
| 116 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
#### Array forms <a id="new.delete.array">[[new.delete.array]]</a>
|
| 119 |
|
| 120 |
``` cpp
|
| 121 |
void* operator new[](std::size_t size);
|
|
@@ -155,50 +200,92 @@ requirement is binding on a replacement version of this function.
|
|
| 155 |
normally, returns the result of that call. Otherwise, returns a null
|
| 156 |
pointer.
|
| 157 |
|
| 158 |
``` cpp
|
| 159 |
void operator delete[](void* ptr) noexcept;
|
|
|
|
| 160 |
```
|
| 161 |
|
| 162 |
*Effects:* The *deallocation
|
| 163 |
function* ([[basic.stc.dynamic.deallocation]]) called by the array form
|
| 164 |
of a *delete-expression* to render the value of `ptr` invalid.
|
| 165 |
|
| 166 |
-
*Replaceable:* a C++program can define a function with
|
| 167 |
-
|
| 168 |
-
library.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
|
| 170 |
*Requires:* *ptr* shall be a null pointer or its value shall be the
|
| 171 |
value returned by an earlier call to `operator new[](std::size_t)` or
|
| 172 |
`operator new[](std::size_t,const std::nothrow_t&)` which has not been
|
| 173 |
invalidated by an intervening call to `operator delete[](void*)`.
|
| 174 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
*Requires:* If an implementation has strict pointer
|
| 176 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 177 |
safely-derived pointer.
|
| 178 |
|
| 179 |
-
*Default behavior:*
|
|
|
|
|
|
|
| 180 |
|
| 181 |
``` cpp
|
| 182 |
void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
|
|
|
|
| 183 |
```
|
| 184 |
|
| 185 |
*Effects:* The *deallocation
|
| 186 |
function* ([[basic.stc.dynamic.deallocation]]) called by the
|
| 187 |
implementation to render the value of `ptr` invalid when the constructor
|
| 188 |
invoked from a nothrow placement version of the array *new-expression*
|
| 189 |
throws an exception.
|
| 190 |
|
| 191 |
-
*Replaceable:* a C++program may define a function with
|
| 192 |
-
|
| 193 |
-
library.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
|
| 195 |
*Requires:* If an implementation has strict pointer
|
| 196 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 197 |
safely-derived pointer.
|
| 198 |
|
| 199 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
|
| 201 |
#### Placement forms <a id="new.delete.placement">[[new.delete.placement]]</a>
|
| 202 |
|
| 203 |
These functions are reserved, a C++program may not define functions that
|
| 204 |
displace the versions in the Standard C++library ([[constraints]]). The
|
|
@@ -259,18 +346,14 @@ operator new terminates by throwing an exception ([[expr.new]]).
|
|
| 259 |
|
| 260 |
#### Data races <a id="new.delete.dataraces">[[new.delete.dataraces]]</a>
|
| 261 |
|
| 262 |
For purposes of determining the existence of data races, the library
|
| 263 |
versions of `operator new`, user replacement versions of global
|
| 264 |
-
`operator new`,
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
argument and by its return value. Calls to these functions that allocate
|
| 273 |
-
or deallocate a particular unit of storage shall occur in a single total
|
| 274 |
-
order, and each such deallocation call shall happen before the next
|
| 275 |
-
allocation (if any) in this order.
|
| 276 |
|
|
|
|
| 60 |
normally, returns the result of that call. Otherwise, returns a null
|
| 61 |
pointer.
|
| 62 |
|
| 63 |
``` cpp
|
| 64 |
T* p1 = new T; // throws bad_alloc if it fails
|
| 65 |
+
T* p2 = new(nothrow) T; // returns nullptr if it fails
|
| 66 |
```
|
| 67 |
|
| 68 |
``` cpp
|
| 69 |
void operator delete(void* ptr) noexcept;
|
| 70 |
+
void operator delete(void* ptr, std::size_t size) noexcept;
|
| 71 |
```
|
| 72 |
|
| 73 |
*Effects:* The *deallocation
|
| 74 |
function* ([[basic.stc.dynamic.deallocation]]) called by a
|
| 75 |
*delete-expression* to render the value of `ptr` invalid.
|
| 76 |
|
| 77 |
+
*Replaceable:* a C++program may define a function with signature
|
| 78 |
+
`void operator delete(void* ptr) noexcept` that displaces the default
|
| 79 |
+
version defined by the C++standard library. If this function (without
|
| 80 |
+
`size` parameter) is defined, the program should also define
|
| 81 |
+
`void operator delete(void* ptr, std::size_t size) noexcept`. If this
|
| 82 |
+
function with `size` parameter is defined, the program shall also define
|
| 83 |
+
the version without the `size` parameter. The default behavior below may
|
| 84 |
+
change in the future, which will require replacing both deallocation
|
| 85 |
+
functions when replacing the allocation function.
|
| 86 |
|
| 87 |
*Requires:* *ptr* shall be a null pointer or its value shall be a value
|
| 88 |
returned by an earlier call to the (possibly replaced)
|
| 89 |
`operator new(std::size_t)` or
|
| 90 |
`operator new(std::size_t,const std::nothrow_t&)` which has not been
|
|
|
|
| 92 |
|
| 93 |
*Requires:* If an implementation has strict pointer
|
| 94 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 95 |
safely-derived pointer.
|
| 96 |
|
| 97 |
+
*Requires:* If present, the `std::size_t size` argument shall equal the
|
| 98 |
+
size argument passed to the allocation function that returned `ptr`.
|
| 99 |
+
|
| 100 |
+
*Required behavior:* Calls to
|
| 101 |
+
`operator delete(void* ptr, std::size_t size)` may be changed to calls
|
| 102 |
+
to `operator delete(void* ptr)` without affecting memory allocation. A
|
| 103 |
+
conforming implementation is for
|
| 104 |
+
`operator delete(void* ptr, std::size_t size)` to simply call
|
| 105 |
+
`operator delete(ptr)`.
|
| 106 |
+
|
| 107 |
+
*Default behavior:* the function
|
| 108 |
+
`operator delete(void* ptr, std::size_t size)` calls
|
| 109 |
+
`operator delete(ptr)`. See the note in the above *Replaceable*
|
| 110 |
+
paragraph.
|
| 111 |
+
|
| 112 |
*Default behavior:* If `ptr` is null, does nothing. Otherwise, reclaims
|
| 113 |
the storage allocated by the earlier call to `operator new`.
|
| 114 |
|
| 115 |
*Remarks:* It is unspecified under what conditions part or all of such
|
| 116 |
reclaimed storage will be allocated by subsequent calls to
|
| 117 |
`operator new` or any of `calloc`, `malloc`, or `realloc`, declared in
|
| 118 |
`<cstdlib>`.
|
| 119 |
|
| 120 |
``` cpp
|
| 121 |
void operator delete(void* ptr, const std::nothrow_t&) noexcept;
|
| 122 |
+
void operator delete(void* ptr, std::size_t size, const std::nothrow_t&) noexcept;
|
| 123 |
```
|
| 124 |
|
| 125 |
*Effects:* The *deallocation
|
| 126 |
function* ([[basic.stc.dynamic.deallocation]]) called by the
|
| 127 |
implementation to render the value of `ptr` invalid when the constructor
|
| 128 |
invoked from a nothrow placement version of the *new-expression* throws
|
| 129 |
an exception.
|
| 130 |
|
| 131 |
+
*Replaceable:* a C++program may define a function with signature
|
| 132 |
+
`void operator delete(void* ptr, const std::nothrow_t&) noexcept` that
|
| 133 |
+
displaces the default version defined by the C++standard library. If
|
| 134 |
+
this function (without `size` parameter) is defined, the program should
|
| 135 |
+
also define
|
| 136 |
+
`void operator delete(void* ptr, std::size_t size, const std::nothrow_t&) noexcept`.
|
| 137 |
+
If this function with `size` parameter is defined, the program shall
|
| 138 |
+
also define the version without the `size` parameter. The default
|
| 139 |
+
behavior below may change in the future, which will require replacing
|
| 140 |
+
both deallocation functions when replacing the allocation function.
|
| 141 |
|
| 142 |
*Requires:* If an implementation has strict pointer
|
| 143 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 144 |
safely-derived pointer.
|
| 145 |
|
| 146 |
+
*Requires:* If present, the `std::size_t size` argument must equal the
|
| 147 |
+
size argument passed to the allocation function that returned `ptr`.
|
| 148 |
+
|
| 149 |
+
*Required behavior:* Calls to
|
| 150 |
+
`operator delete(void* ptr, std::size_t size, const std::nothrow_t&)`
|
| 151 |
+
may be changed to calls to
|
| 152 |
+
`operator delete(void* ptr, const std::nothrow_t&)` without affecting
|
| 153 |
+
memory allocation. A conforming implementation is for
|
| 154 |
+
`operator delete(void* ptr, std::size_t size, const std::nothrow_t&)` to
|
| 155 |
+
simply call `operator delete(void* ptr, const std::nothrow_t&)`.
|
| 156 |
+
|
| 157 |
+
*Default behavior:*
|
| 158 |
+
`operator delete(void* ptr, std::size_t size, const std::nothrow_t&)`
|
| 159 |
+
calls `operator delete(ptr, std::nothrow)`, and
|
| 160 |
+
`operator delete(void* ptr, const std::nothrow_t&)` calls
|
| 161 |
+
`operator delete(ptr)`.
|
| 162 |
|
| 163 |
#### Array forms <a id="new.delete.array">[[new.delete.array]]</a>
|
| 164 |
|
| 165 |
``` cpp
|
| 166 |
void* operator new[](std::size_t size);
|
|
|
|
| 200 |
normally, returns the result of that call. Otherwise, returns a null
|
| 201 |
pointer.
|
| 202 |
|
| 203 |
``` cpp
|
| 204 |
void operator delete[](void* ptr) noexcept;
|
| 205 |
+
void operator delete[](void* ptr, std::size_t size) noexcept;
|
| 206 |
```
|
| 207 |
|
| 208 |
*Effects:* The *deallocation
|
| 209 |
function* ([[basic.stc.dynamic.deallocation]]) called by the array form
|
| 210 |
of a *delete-expression* to render the value of `ptr` invalid.
|
| 211 |
|
| 212 |
+
*Replaceable:* a C++program can define a function with signature
|
| 213 |
+
`void operator delete[](void* ptr) noexcept` that displaces the default
|
| 214 |
+
version defined by the C++standard library. If this function (without
|
| 215 |
+
`size` parameter) is defined, the program should also define
|
| 216 |
+
`void operator delete[](void* ptr, std::size_t size) noexcept`. If this
|
| 217 |
+
function with `size` parameter is defined, the program shall also define
|
| 218 |
+
the version without the `size` parameter. The default behavior below may
|
| 219 |
+
change in the future, which will require replacing both deallocation
|
| 220 |
+
functions when replacing the allocation function.
|
| 221 |
|
| 222 |
*Requires:* *ptr* shall be a null pointer or its value shall be the
|
| 223 |
value returned by an earlier call to `operator new[](std::size_t)` or
|
| 224 |
`operator new[](std::size_t,const std::nothrow_t&)` which has not been
|
| 225 |
invalidated by an intervening call to `operator delete[](void*)`.
|
| 226 |
|
| 227 |
+
*Requires:* If present, the `std::size_t size` argument must equal the
|
| 228 |
+
size argument passed to the allocation function that returned `ptr`.
|
| 229 |
+
|
| 230 |
+
*Required behavior:* Calls to
|
| 231 |
+
`operator delete[](void* ptr, std::size_t size)` may be changed to calls
|
| 232 |
+
to `operator delete[](void* ptr)` without affecting memory allocation. A
|
| 233 |
+
conforming implementation is for
|
| 234 |
+
`operator delete[](void* ptr, std::size_t size)` to simply call
|
| 235 |
+
`operator delete[](void* ptr)`.
|
| 236 |
+
|
| 237 |
*Requires:* If an implementation has strict pointer
|
| 238 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 239 |
safely-derived pointer.
|
| 240 |
|
| 241 |
+
*Default behavior:* `operator delete[](void* ptr, std::size_t size)`
|
| 242 |
+
calls `operator delete[](ptr)`, and `operator delete[](void* ptr)` calls
|
| 243 |
+
`operator delete(ptr)`.
|
| 244 |
|
| 245 |
``` cpp
|
| 246 |
void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
|
| 247 |
+
void operator delete[](void* ptr, std::size_t size, const std::nothrow_t&) noexcept;
|
| 248 |
```
|
| 249 |
|
| 250 |
*Effects:* The *deallocation
|
| 251 |
function* ([[basic.stc.dynamic.deallocation]]) called by the
|
| 252 |
implementation to render the value of `ptr` invalid when the constructor
|
| 253 |
invoked from a nothrow placement version of the array *new-expression*
|
| 254 |
throws an exception.
|
| 255 |
|
| 256 |
+
*Replaceable:* a C++program may define a function with signature
|
| 257 |
+
`void operator delete[](void* ptr, const std::nothrow_t&) noexcept` that
|
| 258 |
+
displaces the default version defined by the C++standard library. If
|
| 259 |
+
this function (without `size` parameter) is defined, the program should
|
| 260 |
+
also define
|
| 261 |
+
`void operator delete[](void* ptr, std::size_t size, const std::nothrow_t&) noexcept`.
|
| 262 |
+
If this function with `size` parameter is defined, the program shall
|
| 263 |
+
also define the version without the `size` parameter. The default
|
| 264 |
+
behavior below may change in the future, which will require replacing
|
| 265 |
+
both deallocation functions when replacing the allocation function.
|
| 266 |
|
| 267 |
*Requires:* If an implementation has strict pointer
|
| 268 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 269 |
safely-derived pointer.
|
| 270 |
|
| 271 |
+
*Requires:* If present, the `std::size_t size` argument must equal the
|
| 272 |
+
size argument passed to the allocation function that returned `ptr`.
|
| 273 |
+
|
| 274 |
+
*Required behavior:* Calls to
|
| 275 |
+
`operator delete[](void* ptr, std::size_t size, const std::nothrow_t&)`
|
| 276 |
+
may be changed to calls to
|
| 277 |
+
`operator delete[](void* ptr, const std::nothrow_t&)` without affecting
|
| 278 |
+
memory allocation. A conforming implementation is for
|
| 279 |
+
`operator delete[](void* ptr, std::size_t size, const std::nothrow_t&)`
|
| 280 |
+
to simply call `operator delete[](void* ptr, const std::nothrow_t&)`.
|
| 281 |
+
|
| 282 |
+
*Default behavior:*
|
| 283 |
+
`operator delete[](void* ptr, std::size_t size, const std::nothrow_t&)`
|
| 284 |
+
calls `operator delete[](ptr, std::nothrow)`, and
|
| 285 |
+
`operator delete[](void* ptr, const std::nothrow_t&)` calls
|
| 286 |
+
`operator delete[](ptr)`.
|
| 287 |
|
| 288 |
#### Placement forms <a id="new.delete.placement">[[new.delete.placement]]</a>
|
| 289 |
|
| 290 |
These functions are reserved, a C++program may not define functions that
|
| 291 |
displace the versions in the Standard C++library ([[constraints]]). The
|
|
|
|
| 346 |
|
| 347 |
#### Data races <a id="new.delete.dataraces">[[new.delete.dataraces]]</a>
|
| 348 |
|
| 349 |
For purposes of determining the existence of data races, the library
|
| 350 |
versions of `operator new`, user replacement versions of global
|
| 351 |
+
`operator new`, the C standard library functions `calloc` and `malloc`,
|
| 352 |
+
the library versions of `operator delete`, user replacement versions of
|
| 353 |
+
`operator delete`, the C standard library function `free`, and the C
|
| 354 |
+
standard library function `realloc` shall not introduce a data race (
|
| 355 |
+
[[res.on.data.races]]). Calls to these functions that allocate or
|
| 356 |
+
deallocate a particular unit of storage shall occur in a single total
|
| 357 |
+
order, and each such deallocation call shall happen before (
|
| 358 |
+
[[intro.multithread]]) the next allocation (if any) in this order.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 359 |
|