tmp/tmptwtftzst/{from.md → to.md}
RENAMED
|
@@ -1,21 +1,17 @@
|
|
| 1 |
#### Single-object forms <a id="new.delete.single">[[new.delete.single]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
-
|
| 5 |
-
|
| 6 |
```
|
| 7 |
|
| 8 |
*Effects:* The allocation functions [[basic.stc.dynamic.allocation]]
|
| 9 |
called by a *new-expression*[[expr.new]] to allocate `size` bytes of
|
| 10 |
storage. The second form is called for a type with new-extended
|
| 11 |
alignment, and the first form is called otherwise.
|
| 12 |
|
| 13 |
-
*Replaceable:* A C++ program may define functions with either of these
|
| 14 |
-
function signatures, and thereby displace the default versions defined
|
| 15 |
-
by the C++ standard library.
|
| 16 |
-
|
| 17 |
*Required behavior:* Return a non-null pointer to suitably aligned
|
| 18 |
storage [[basic.stc.dynamic]], or else throw a `bad_alloc` exception.
|
| 19 |
This requirement is binding on any replacement versions of these
|
| 20 |
functions.
|
| 21 |
|
|
@@ -32,24 +28,21 @@ functions.
|
|
| 32 |
function [[new.handler]]. If the called function returns, the loop
|
| 33 |
repeats.
|
| 34 |
- The loop terminates when an attempt to allocate the requested storage
|
| 35 |
is successful or when a called `new_handler` function does not return.
|
| 36 |
|
|
|
|
|
|
|
| 37 |
``` cpp
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
const std::nothrow_t&) noexcept;
|
| 41 |
```
|
| 42 |
|
| 43 |
*Effects:* Same as above, except that these are called by a placement
|
| 44 |
version of a *new-expression* when a C++ program prefers a null pointer
|
| 45 |
result as an error indication, instead of a `bad_alloc` exception.
|
| 46 |
|
| 47 |
-
*Replaceable:* A C++ program may define functions with either of these
|
| 48 |
-
function signatures, and thereby displace the default versions defined
|
| 49 |
-
by the C++ standard library.
|
| 50 |
-
|
| 51 |
*Required behavior:* Return a non-null pointer to suitably aligned
|
| 52 |
storage [[basic.stc.dynamic]], or else return a null pointer. Each of
|
| 53 |
these nothrow versions of `operator new` returns a pointer obtained as
|
| 54 |
if acquired from the (possibly replaced) corresponding non-placement
|
| 55 |
function. This requirement is binding on any replacement versions of
|
|
@@ -67,10 +60,12 @@ T* p1 = new T; // throws bad_alloc if it fails
|
|
| 67 |
T* p2 = new(nothrow) T; // returns nullptr if it fails
|
| 68 |
```
|
| 69 |
|
| 70 |
— *end example*]
|
| 71 |
|
|
|
|
|
|
|
| 72 |
``` cpp
|
| 73 |
void operator delete(void* ptr) noexcept;
|
| 74 |
void operator delete(void* ptr, std::size_t size) noexcept;
|
| 75 |
void operator delete(void* ptr, std::align_val_t alignment) noexcept;
|
| 76 |
void operator delete(void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
|
|
@@ -91,46 +86,43 @@ returned `ptr`.
|
|
| 91 |
|
| 92 |
*Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
|
| 93 |
called by a *delete-expression*[[expr.delete]] to render the value of
|
| 94 |
`ptr` invalid.
|
| 95 |
|
| 96 |
-
*Replaceable:* A C++ program may define functions with any of these
|
| 97 |
-
function signatures, and thereby displace the default versions defined
|
| 98 |
-
by the C++ standard library.
|
| 99 |
-
|
| 100 |
-
If a function without a `size` parameter is defined, the program should
|
| 101 |
-
also define the corresponding function with a `size` parameter. If a
|
| 102 |
-
function with a `size` parameter is defined, the program shall also
|
| 103 |
-
define the corresponding version without the `size` parameter.
|
| 104 |
-
|
| 105 |
-
[*Note 1*: The default behavior below might change in the future, which
|
| 106 |
-
will require replacing both deallocation functions when replacing the
|
| 107 |
-
allocation function. — *end note*]
|
| 108 |
-
|
| 109 |
*Required behavior:* A call to an `operator delete` with a `size`
|
| 110 |
parameter may be changed to a call to the corresponding
|
| 111 |
`operator delete` without a `size` parameter, without affecting memory
|
| 112 |
allocation.
|
| 113 |
|
| 114 |
-
[*Note
|
| 115 |
`operator delete(void* ptr, std::size_t size)` to simply call
|
| 116 |
`operator delete(ptr)`. — *end note*]
|
| 117 |
|
| 118 |
*Default behavior:* The functions that have a `size` parameter forward
|
| 119 |
their other parameters to the corresponding function without a `size`
|
| 120 |
parameter.
|
| 121 |
|
| 122 |
-
[*Note
|
| 123 |
paragraph. — *end note*]
|
| 124 |
|
| 125 |
*Default behavior:* If `ptr` is null, does nothing. Otherwise, reclaims
|
| 126 |
the storage allocated by the earlier call to `operator new`.
|
| 127 |
|
| 128 |
*Remarks:* It is unspecified under what conditions part or all of such
|
| 129 |
reclaimed storage will be allocated by subsequent calls to
|
| 130 |
`operator new` or any of `aligned_alloc`, `calloc`, `malloc`, or
|
| 131 |
-
`realloc`, declared in `<cstdlib>`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
|
| 133 |
``` cpp
|
| 134 |
void operator delete(void* ptr, const std::nothrow_t&) noexcept;
|
| 135 |
void operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
|
| 136 |
```
|
|
@@ -149,12 +141,10 @@ allocation function that returned `ptr`.
|
|
| 149 |
*Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
|
| 150 |
called by the implementation to render the value of `ptr` invalid when
|
| 151 |
the constructor invoked from a nothrow placement version of the
|
| 152 |
*new-expression* throws an exception.
|
| 153 |
|
| 154 |
-
*Replaceable:* A C++ program may define functions with either of these
|
| 155 |
-
function signatures, and thereby displace the default versions defined
|
| 156 |
-
by the C++ standard library.
|
| 157 |
-
|
| 158 |
*Default behavior:* Calls `operator delete(ptr)`, or
|
| 159 |
`operator delete(ptr, alignment)`, respectively.
|
| 160 |
|
|
|
|
|
|
|
|
|
| 1 |
#### Single-object forms <a id="new.delete.single">[[new.delete.single]]</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 a *new-expression*[[expr.new]] to allocate `size` bytes of
|
| 10 |
storage. The second form is called for a type with new-extended
|
| 11 |
alignment, and the first form is called otherwise.
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
*Required behavior:* Return a non-null pointer to suitably aligned
|
| 14 |
storage [[basic.stc.dynamic]], or else throw a `bad_alloc` exception.
|
| 15 |
This requirement is binding on any replacement versions of these
|
| 16 |
functions.
|
| 17 |
|
|
|
|
| 28 |
function [[new.handler]]. If the called function returns, the loop
|
| 29 |
repeats.
|
| 30 |
- The loop terminates when an attempt to allocate the requested storage
|
| 31 |
is successful or when a called `new_handler` function does not return.
|
| 32 |
|
| 33 |
+
*Remarks:* This function is replaceable [[term.replaceable.function]].
|
| 34 |
+
|
| 35 |
``` cpp
|
| 36 |
+
void* operator new(std::size_t size, const std::nothrow_t&) noexcept;
|
| 37 |
+
void* operator new(std::size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept;
|
|
|
|
| 38 |
```
|
| 39 |
|
| 40 |
*Effects:* Same as above, except that these are called by a placement
|
| 41 |
version of a *new-expression* when a C++ program prefers a null pointer
|
| 42 |
result as an error indication, instead of a `bad_alloc` exception.
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
*Required behavior:* Return a non-null pointer to suitably aligned
|
| 45 |
storage [[basic.stc.dynamic]], or else return a null pointer. Each of
|
| 46 |
these nothrow versions of `operator new` returns a pointer obtained as
|
| 47 |
if acquired from the (possibly replaced) corresponding non-placement
|
| 48 |
function. This requirement is binding on any replacement versions of
|
|
|
|
| 60 |
T* p2 = new(nothrow) T; // returns nullptr if it fails
|
| 61 |
```
|
| 62 |
|
| 63 |
— *end example*]
|
| 64 |
|
| 65 |
+
*Remarks:* This function is replaceable [[term.replaceable.function]].
|
| 66 |
+
|
| 67 |
``` cpp
|
| 68 |
void operator delete(void* ptr) noexcept;
|
| 69 |
void operator delete(void* ptr, std::size_t size) noexcept;
|
| 70 |
void operator delete(void* ptr, std::align_val_t alignment) noexcept;
|
| 71 |
void operator delete(void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
|
|
|
|
| 86 |
|
| 87 |
*Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
|
| 88 |
called by a *delete-expression*[[expr.delete]] to render the value of
|
| 89 |
`ptr` invalid.
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
*Required behavior:* A call to an `operator delete` with a `size`
|
| 92 |
parameter may be changed to a call to the corresponding
|
| 93 |
`operator delete` without a `size` parameter, without affecting memory
|
| 94 |
allocation.
|
| 95 |
|
| 96 |
+
[*Note 1*: A conforming implementation is for
|
| 97 |
`operator delete(void* ptr, std::size_t size)` to simply call
|
| 98 |
`operator delete(ptr)`. — *end note*]
|
| 99 |
|
| 100 |
*Default behavior:* The functions that have a `size` parameter forward
|
| 101 |
their other parameters to the corresponding function without a `size`
|
| 102 |
parameter.
|
| 103 |
|
| 104 |
+
[*Note 2*: See the note in the below *Remarks:*
|
| 105 |
paragraph. — *end note*]
|
| 106 |
|
| 107 |
*Default behavior:* If `ptr` is null, does nothing. Otherwise, reclaims
|
| 108 |
the storage allocated by the earlier call to `operator new`.
|
| 109 |
|
| 110 |
*Remarks:* It is unspecified under what conditions part or all of such
|
| 111 |
reclaimed storage will be allocated by subsequent calls to
|
| 112 |
`operator new` or any of `aligned_alloc`, `calloc`, `malloc`, or
|
| 113 |
+
`realloc`, declared in `<cstdlib>`. This function is
|
| 114 |
+
replaceable [[term.replaceable.function]]. If a replacement function
|
| 115 |
+
without a `size` parameter is defined by the program, the program should
|
| 116 |
+
also define the corresponding function with a `size` parameter. If a
|
| 117 |
+
replacement function with a `size` parameter is defined by the program,
|
| 118 |
+
the program shall also define the corresponding version without the
|
| 119 |
+
`size` parameter.
|
| 120 |
+
|
| 121 |
+
[*Note 3*: The default behavior above might change in the future, which
|
| 122 |
+
will require replacing both deallocation functions when replacing the
|
| 123 |
+
allocation function. — *end note*]
|
| 124 |
|
| 125 |
``` cpp
|
| 126 |
void operator delete(void* ptr, const std::nothrow_t&) noexcept;
|
| 127 |
void operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
|
| 128 |
```
|
|
|
|
| 141 |
*Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
|
| 142 |
called by the implementation to render the value of `ptr` invalid when
|
| 143 |
the constructor invoked from a nothrow placement version of the
|
| 144 |
*new-expression* throws an exception.
|
| 145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
*Default behavior:* Calls `operator delete(ptr)`, or
|
| 147 |
`operator delete(ptr, alignment)`, respectively.
|
| 148 |
|
| 149 |
+
*Remarks:* This function is replaceable [[term.replaceable.function]].
|
| 150 |
+
|