tmp/tmpz8pzn8pe/{from.md → to.md}
RENAMED
|
@@ -14,29 +14,25 @@ global *deallocation functions* `operator delete` and
|
|
| 14 |
[[new.delete.placement]] do not perform allocation or
|
| 15 |
deallocation. — *end note*]
|
| 16 |
|
| 17 |
The library provides default definitions for the global allocation and
|
| 18 |
deallocation functions. Some global allocation and deallocation
|
| 19 |
-
functions are replaceable [[
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
such function definition replaces the default version provided in the
|
| 23 |
-
library [[replacement.functions]]. The following allocation and
|
| 24 |
-
deallocation functions [[support.dynamic]] are implicitly declared in
|
| 25 |
-
global scope in each translation unit of a program.
|
| 26 |
|
| 27 |
``` cpp
|
| 28 |
-
|
| 29 |
-
|
| 30 |
|
| 31 |
void operator delete(void*) noexcept;
|
| 32 |
void operator delete(void*, std::size_t) noexcept;
|
| 33 |
void operator delete(void*, std::align_val_t) noexcept;
|
| 34 |
void operator delete(void*, std::size_t, std::align_val_t) noexcept;
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
|
| 39 |
void operator delete[](void*) noexcept;
|
| 40 |
void operator delete[](void*, std::size_t) noexcept;
|
| 41 |
void operator delete[](void*, std::align_val_t) noexcept;
|
| 42 |
void operator delete[](void*, std::size_t, std::align_val_t) noexcept;
|
|
@@ -91,11 +87,11 @@ from any previously returned value `p1`, unless that value `p1` was
|
|
| 91 |
subsequently passed to a replaceable deallocation function. Furthermore,
|
| 92 |
for the library allocation functions in [[new.delete.single]] and
|
| 93 |
[[new.delete.array]], `p0` represents the address of a block of storage
|
| 94 |
disjoint from the storage for any other object accessible to the caller.
|
| 95 |
The effect of indirecting through a pointer returned from a request for
|
| 96 |
-
zero size is undefined.[^
|
| 97 |
|
| 98 |
For an allocation function other than a reserved placement allocation
|
| 99 |
function [[new.delete.placement]], the pointer returned on a successful
|
| 100 |
call shall represent the address of storage that is aligned as follows:
|
| 101 |
|
|
@@ -110,12 +106,12 @@ call shall represent the address of storage that is aligned as follows:
|
|
| 110 |
|
| 111 |
An allocation function that fails to allocate storage can invoke the
|
| 112 |
currently installed new-handler function [[new.handler]], if any.
|
| 113 |
|
| 114 |
[*Note 3*: A program-supplied allocation function can obtain the
|
| 115 |
-
|
| 116 |
-
|
| 117 |
|
| 118 |
An allocation function that has a non-throwing exception specification
|
| 119 |
[[except.spec]] indicates failure by returning a null pointer value. Any
|
| 120 |
other allocation function never returns a null pointer value and
|
| 121 |
indicates failure only by throwing an exception [[except.throw]] of a
|
|
@@ -130,11 +126,13 @@ calls to the functions in the C++ standard library.
|
|
| 130 |
|
| 131 |
[*Note 4*: In particular, a global allocation function is not called to
|
| 132 |
allocate storage for objects with static storage duration
|
| 133 |
[[basic.stc.static]], for objects or references with thread storage
|
| 134 |
duration [[basic.stc.thread]], for objects of type `std::type_info`
|
| 135 |
-
[[expr.typeid]],
|
|
|
|
|
|
|
| 136 |
[[except.throw]]. — *end note*]
|
| 137 |
|
| 138 |
##### Deallocation functions <a id="basic.stc.dynamic.deallocation">[[basic.stc.dynamic.deallocation]]</a>
|
| 139 |
|
| 140 |
A deallocation function that is not a class member function shall belong
|
|
@@ -154,11 +152,11 @@ first parameter shall be `C*`; otherwise, the type of its first
|
|
| 154 |
parameter shall be `void*`. A deallocation function may have more than
|
| 155 |
one parameter. A *usual deallocation function* is a deallocation
|
| 156 |
function whose parameters after the first are
|
| 157 |
|
| 158 |
- optionally, a parameter of type `std::destroying_delete_t`, then
|
| 159 |
-
- optionally, a parameter of type `std::size_t`,[^
|
| 160 |
- optionally, a parameter of type `std::align_val_t`.
|
| 161 |
|
| 162 |
A destroying operator delete shall be a usual deallocation function. A
|
| 163 |
deallocation function may be an instance of a function template. Neither
|
| 164 |
the first parameter nor the return type shall depend on a template
|
|
|
|
| 14 |
[[new.delete.placement]] do not perform allocation or
|
| 15 |
deallocation. — *end note*]
|
| 16 |
|
| 17 |
The library provides default definitions for the global allocation and
|
| 18 |
deallocation functions. Some global allocation and deallocation
|
| 19 |
+
functions are replaceable [[term.replaceable.function]]. The following
|
| 20 |
+
allocation and deallocation functions [[support.dynamic]] are implicitly
|
| 21 |
+
declared in global scope in each translation unit of a program.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
``` cpp
|
| 24 |
+
void* operator new(std::size_t);
|
| 25 |
+
void* operator new(std::size_t, std::align_val_t);
|
| 26 |
|
| 27 |
void operator delete(void*) noexcept;
|
| 28 |
void operator delete(void*, std::size_t) noexcept;
|
| 29 |
void operator delete(void*, std::align_val_t) noexcept;
|
| 30 |
void operator delete(void*, std::size_t, std::align_val_t) noexcept;
|
| 31 |
|
| 32 |
+
void* operator new[](std::size_t);
|
| 33 |
+
void* operator new[](std::size_t, std::align_val_t);
|
| 34 |
|
| 35 |
void operator delete[](void*) noexcept;
|
| 36 |
void operator delete[](void*, std::size_t) noexcept;
|
| 37 |
void operator delete[](void*, std::align_val_t) noexcept;
|
| 38 |
void operator delete[](void*, std::size_t, std::align_val_t) noexcept;
|
|
|
|
| 87 |
subsequently passed to a replaceable deallocation function. Furthermore,
|
| 88 |
for the library allocation functions in [[new.delete.single]] and
|
| 89 |
[[new.delete.array]], `p0` represents the address of a block of storage
|
| 90 |
disjoint from the storage for any other object accessible to the caller.
|
| 91 |
The effect of indirecting through a pointer returned from a request for
|
| 92 |
+
zero size is undefined.[^9]
|
| 93 |
|
| 94 |
For an allocation function other than a reserved placement allocation
|
| 95 |
function [[new.delete.placement]], the pointer returned on a successful
|
| 96 |
call shall represent the address of storage that is aligned as follows:
|
| 97 |
|
|
|
|
| 106 |
|
| 107 |
An allocation function that fails to allocate storage can invoke the
|
| 108 |
currently installed new-handler function [[new.handler]], if any.
|
| 109 |
|
| 110 |
[*Note 3*: A program-supplied allocation function can obtain the
|
| 111 |
+
currently installed `new_handler` using the `std::get_new_handler`
|
| 112 |
+
function [[get.new.handler]]. — *end note*]
|
| 113 |
|
| 114 |
An allocation function that has a non-throwing exception specification
|
| 115 |
[[except.spec]] indicates failure by returning a null pointer value. Any
|
| 116 |
other allocation function never returns a null pointer value and
|
| 117 |
indicates failure only by throwing an exception [[except.throw]] of a
|
|
|
|
| 126 |
|
| 127 |
[*Note 4*: In particular, a global allocation function is not called to
|
| 128 |
allocate storage for objects with static storage duration
|
| 129 |
[[basic.stc.static]], for objects or references with thread storage
|
| 130 |
duration [[basic.stc.thread]], for objects of type `std::type_info`
|
| 131 |
+
[[expr.typeid]], for an object of type
|
| 132 |
+
`std::contracts::contract_violation` when a contract violation occurs
|
| 133 |
+
[[basic.contract.eval]], or for an exception object
|
| 134 |
[[except.throw]]. — *end note*]
|
| 135 |
|
| 136 |
##### Deallocation functions <a id="basic.stc.dynamic.deallocation">[[basic.stc.dynamic.deallocation]]</a>
|
| 137 |
|
| 138 |
A deallocation function that is not a class member function shall belong
|
|
|
|
| 152 |
parameter shall be `void*`. A deallocation function may have more than
|
| 153 |
one parameter. A *usual deallocation function* is a deallocation
|
| 154 |
function whose parameters after the first are
|
| 155 |
|
| 156 |
- optionally, a parameter of type `std::destroying_delete_t`, then
|
| 157 |
+
- optionally, a parameter of type `std::size_t`,[^10] then
|
| 158 |
- optionally, a parameter of type `std::align_val_t`.
|
| 159 |
|
| 160 |
A destroying operator delete shall be a usual deallocation function. A
|
| 161 |
deallocation function may be an instance of a function template. Neither
|
| 162 |
the first parameter nor the return type shall depend on a template
|