tmp/tmpxy9b9o7n/{from.md → to.md}
RENAMED
|
@@ -53,24 +53,31 @@ is binding on a replacement version of this function.
|
|
| 53 |
normally, returns the result of that call. Otherwise, returns a null
|
| 54 |
pointer.
|
| 55 |
|
| 56 |
``` cpp
|
| 57 |
T* p1 = new T; // throws bad_alloc if it fails
|
| 58 |
-
T* p2 = new(nothrow) T; // returns
|
| 59 |
```
|
| 60 |
|
| 61 |
``` cpp
|
| 62 |
void operator delete(void* ptr) noexcept;
|
|
|
|
| 63 |
```
|
| 64 |
|
| 65 |
*Effects:* The *deallocation
|
| 66 |
function* ([[basic.stc.dynamic.deallocation]]) called by a
|
| 67 |
*delete-expression* to render the value of `ptr` invalid.
|
| 68 |
|
| 69 |
-
*Replaceable:* a C++program may define a function with
|
| 70 |
-
|
| 71 |
-
library.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
*Requires:* *ptr* shall be a null pointer or its value shall be a value
|
| 74 |
returned by an earlier call to the (possibly replaced)
|
| 75 |
`operator new(std::size_t)` or
|
| 76 |
`operator new(std::size_t,const std::nothrow_t&)` which has not been
|
|
@@ -78,33 +85,71 @@ invalidated by an intervening call to `operator delete(void*)`.
|
|
| 78 |
|
| 79 |
*Requires:* If an implementation has strict pointer
|
| 80 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 81 |
safely-derived pointer.
|
| 82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
*Default behavior:* If `ptr` is null, does nothing. Otherwise, reclaims
|
| 84 |
the storage allocated by the earlier call to `operator new`.
|
| 85 |
|
| 86 |
*Remarks:* It is unspecified under what conditions part or all of such
|
| 87 |
reclaimed storage will be allocated by subsequent calls to
|
| 88 |
`operator new` or any of `calloc`, `malloc`, or `realloc`, declared in
|
| 89 |
`<cstdlib>`.
|
| 90 |
|
| 91 |
``` cpp
|
| 92 |
void operator delete(void* ptr, const std::nothrow_t&) noexcept;
|
|
|
|
| 93 |
```
|
| 94 |
|
| 95 |
*Effects:* The *deallocation
|
| 96 |
function* ([[basic.stc.dynamic.deallocation]]) called by the
|
| 97 |
implementation to render the value of `ptr` invalid when the constructor
|
| 98 |
invoked from a nothrow placement version of the *new-expression* throws
|
| 99 |
an exception.
|
| 100 |
|
| 101 |
-
*Replaceable:* a C++program may define a function with
|
| 102 |
-
|
| 103 |
-
library.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
|
|
|
| 53 |
normally, returns the result of that call. Otherwise, returns a null
|
| 54 |
pointer.
|
| 55 |
|
| 56 |
``` cpp
|
| 57 |
T* p1 = new T; // throws bad_alloc if it fails
|
| 58 |
+
T* p2 = new(nothrow) T; // returns nullptr if it fails
|
| 59 |
```
|
| 60 |
|
| 61 |
``` cpp
|
| 62 |
void operator delete(void* ptr) noexcept;
|
| 63 |
+
void operator delete(void* ptr, std::size_t size) noexcept;
|
| 64 |
```
|
| 65 |
|
| 66 |
*Effects:* The *deallocation
|
| 67 |
function* ([[basic.stc.dynamic.deallocation]]) called by a
|
| 68 |
*delete-expression* to render the value of `ptr` invalid.
|
| 69 |
|
| 70 |
+
*Replaceable:* a C++program may define a function with signature
|
| 71 |
+
`void operator delete(void* ptr) noexcept` that displaces the default
|
| 72 |
+
version defined by the C++standard library. If this function (without
|
| 73 |
+
`size` parameter) is defined, the program should also define
|
| 74 |
+
`void operator delete(void* ptr, std::size_t size) noexcept`. If this
|
| 75 |
+
function with `size` parameter is defined, the program shall also define
|
| 76 |
+
the version without the `size` parameter. The default behavior below may
|
| 77 |
+
change in the future, which will require replacing both deallocation
|
| 78 |
+
functions when replacing the allocation function.
|
| 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 |
|
| 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 |
+
*Requires:* If present, the `std::size_t size` argument shall equal the
|
| 91 |
+
size argument passed to the allocation function that returned `ptr`.
|
| 92 |
+
|
| 93 |
+
*Required behavior:* Calls to
|
| 94 |
+
`operator delete(void* ptr, std::size_t size)` may be changed to calls
|
| 95 |
+
to `operator delete(void* ptr)` without affecting memory allocation. A
|
| 96 |
+
conforming implementation is for
|
| 97 |
+
`operator delete(void* ptr, std::size_t size)` to simply call
|
| 98 |
+
`operator delete(ptr)`.
|
| 99 |
+
|
| 100 |
+
*Default behavior:* the function
|
| 101 |
+
`operator delete(void* ptr, std::size_t size)` calls
|
| 102 |
+
`operator delete(ptr)`. See the note in the above *Replaceable*
|
| 103 |
+
paragraph.
|
| 104 |
+
|
| 105 |
*Default behavior:* If `ptr` is null, does nothing. Otherwise, reclaims
|
| 106 |
the storage allocated by the earlier call to `operator new`.
|
| 107 |
|
| 108 |
*Remarks:* It is unspecified under what conditions part or all of such
|
| 109 |
reclaimed storage will be allocated by subsequent calls to
|
| 110 |
`operator new` or any of `calloc`, `malloc`, or `realloc`, declared in
|
| 111 |
`<cstdlib>`.
|
| 112 |
|
| 113 |
``` cpp
|
| 114 |
void operator delete(void* ptr, const std::nothrow_t&) noexcept;
|
| 115 |
+
void operator delete(void* ptr, std::size_t size, const std::nothrow_t&) noexcept;
|
| 116 |
```
|
| 117 |
|
| 118 |
*Effects:* The *deallocation
|
| 119 |
function* ([[basic.stc.dynamic.deallocation]]) called by the
|
| 120 |
implementation to render the value of `ptr` invalid when the constructor
|
| 121 |
invoked from a nothrow placement version of the *new-expression* throws
|
| 122 |
an exception.
|
| 123 |
|
| 124 |
+
*Replaceable:* a C++program may define a function with signature
|
| 125 |
+
`void operator delete(void* ptr, const std::nothrow_t&) noexcept` that
|
| 126 |
+
displaces the default version defined by the C++standard library. If
|
| 127 |
+
this function (without `size` parameter) is defined, the program should
|
| 128 |
+
also define
|
| 129 |
+
`void operator delete(void* ptr, std::size_t size, const std::nothrow_t&) noexcept`.
|
| 130 |
+
If this function with `size` parameter is defined, the program shall
|
| 131 |
+
also define the version without the `size` parameter. The default
|
| 132 |
+
behavior below may change in the future, which will require replacing
|
| 133 |
+
both deallocation functions when replacing the allocation function.
|
| 134 |
|
| 135 |
*Requires:* If an implementation has strict pointer
|
| 136 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 137 |
safely-derived pointer.
|
| 138 |
|
| 139 |
+
*Requires:* If present, the `std::size_t size` argument must equal the
|
| 140 |
+
size argument passed to the allocation function that returned `ptr`.
|
| 141 |
+
|
| 142 |
+
*Required behavior:* Calls to
|
| 143 |
+
`operator delete(void* ptr, std::size_t size, const std::nothrow_t&)`
|
| 144 |
+
may be changed to calls to
|
| 145 |
+
`operator delete(void* ptr, const std::nothrow_t&)` without affecting
|
| 146 |
+
memory allocation. A conforming implementation is for
|
| 147 |
+
`operator delete(void* ptr, std::size_t size, const std::nothrow_t&)` to
|
| 148 |
+
simply call `operator delete(void* ptr, const std::nothrow_t&)`.
|
| 149 |
+
|
| 150 |
+
*Default behavior:*
|
| 151 |
+
`operator delete(void* ptr, std::size_t size, const std::nothrow_t&)`
|
| 152 |
+
calls `operator delete(ptr, std::nothrow)`, and
|
| 153 |
+
`operator delete(void* ptr, const std::nothrow_t&)` calls
|
| 154 |
+
`operator delete(ptr)`.
|
| 155 |
|