tmp/tmphmtq_kz_/{from.md → to.md}
RENAMED
|
@@ -10,13 +10,14 @@ delete-expression:
|
|
| 10 |
```
|
| 11 |
|
| 12 |
The first alternative is for non-array objects, and the second is for
|
| 13 |
arrays. Whenever the `delete` keyword is immediately followed by empty
|
| 14 |
square brackets, it shall be interpreted as the second alternative.[^20]
|
| 15 |
-
The operand shall
|
| 16 |
-
|
| 17 |
-
|
|
|
|
| 18 |
|
| 19 |
If the operand has a class type, the operand is converted to a pointer
|
| 20 |
type by calling the above-mentioned conversion function, and the
|
| 21 |
converted operand is used in place of the original operand for the
|
| 22 |
remainder of this section. In the first alternative (*delete object*),
|
|
@@ -55,25 +56,58 @@ any) for the object or the elements of the array being deleted. In the
|
|
| 55 |
case of an array, the elements will be destroyed in order of decreasing
|
| 56 |
address (that is, in reverse order of the completion of their
|
| 57 |
constructor; see [[class.base.init]]).
|
| 58 |
|
| 59 |
If the value of the operand of the *delete-expression* is not a null
|
| 60 |
-
pointer value,
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
An implementation provides default definitions of the global
|
| 67 |
deallocation functions `operator delete()` for non-arrays (
|
| 68 |
[[new.delete.single]]) and `operator delete[]()` for arrays (
|
| 69 |
[[new.delete.array]]). A C++ program can provide alternative definitions
|
| 70 |
of these functions ([[replacement.functions]]), and/or class-specific
|
| 71 |
versions ([[class.free]]).
|
| 72 |
|
| 73 |
When the keyword `delete` in a *delete-expression* is preceded by the
|
| 74 |
-
unary `::` operator, the
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
Access and ambiguity control are done for both the deallocation function
|
| 78 |
and the destructor ([[class.dtor]], [[class.free]]).
|
| 79 |
|
|
|
|
| 10 |
```
|
| 11 |
|
| 12 |
The first alternative is for non-array objects, and the second is for
|
| 13 |
arrays. Whenever the `delete` keyword is immediately followed by empty
|
| 14 |
square brackets, it shall be interpreted as the second alternative.[^20]
|
| 15 |
+
The operand shall be of pointer to object type or of class type. If of
|
| 16 |
+
class type, the operand is contextually implicitly converted (Clause
|
| 17 |
+
[[conv]]) to a pointer to object type.[^21] The *delete-expression*’s
|
| 18 |
+
result has type `void`.
|
| 19 |
|
| 20 |
If the operand has a class type, the operand is converted to a pointer
|
| 21 |
type by calling the above-mentioned conversion function, and the
|
| 22 |
converted operand is used in place of the original operand for the
|
| 23 |
remainder of this section. In the first alternative (*delete object*),
|
|
|
|
| 56 |
case of an array, the elements will be destroyed in order of decreasing
|
| 57 |
address (that is, in reverse order of the completion of their
|
| 58 |
constructor; see [[class.base.init]]).
|
| 59 |
|
| 60 |
If the value of the operand of the *delete-expression* is not a null
|
| 61 |
+
pointer value, then:
|
| 62 |
+
|
| 63 |
+
- If the allocation call for the *new-expression* for the object to be
|
| 64 |
+
deleted was not omitted and the allocation was not extended (
|
| 65 |
+
[[expr.new]]), the *delete-expression* shall call a deallocation
|
| 66 |
+
function ([[basic.stc.dynamic.deallocation]]). The value returned
|
| 67 |
+
from the allocation call of the *new-expression* shall be passed as
|
| 68 |
+
the first argument to the deallocation function.
|
| 69 |
+
- Otherwise, if the allocation was extended or was provided by extending
|
| 70 |
+
the allocation of another *new-expression*, and the
|
| 71 |
+
*delete-expression* for every other pointer value produced by a
|
| 72 |
+
*new-expression* that had storage provided by the extended
|
| 73 |
+
*new-expression* has been evaluated, the *delete-expression* shall
|
| 74 |
+
call a deallocation function. The value returned from the allocation
|
| 75 |
+
call of the extended *new-expression* shall be passed as the first
|
| 76 |
+
argument to the deallocation function.
|
| 77 |
+
- Otherwise, the *delete-expression* will not call a *deallocation
|
| 78 |
+
function* ([[basic.stc.dynamic.deallocation]]).
|
| 79 |
+
|
| 80 |
+
Otherwise, it is unspecified whether the deallocation function will be
|
| 81 |
+
called. The deallocation function is called regardless of whether the
|
| 82 |
+
destructor for the object or some element of the array throws an
|
| 83 |
+
exception.
|
| 84 |
|
| 85 |
An implementation provides default definitions of the global
|
| 86 |
deallocation functions `operator delete()` for non-arrays (
|
| 87 |
[[new.delete.single]]) and `operator delete[]()` for arrays (
|
| 88 |
[[new.delete.array]]). A C++ program can provide alternative definitions
|
| 89 |
of these functions ([[replacement.functions]]), and/or class-specific
|
| 90 |
versions ([[class.free]]).
|
| 91 |
|
| 92 |
When the keyword `delete` in a *delete-expression* is preceded by the
|
| 93 |
+
unary `::` operator, the deallocation function’s name is looked up in
|
| 94 |
+
global scope. Otherwise, the lookup considers class-specific
|
| 95 |
+
deallocation functions ([[class.free]]). If no class-specific
|
| 96 |
+
deallocation function is found, the deallocation function’s name is
|
| 97 |
+
looked up in global scope.
|
| 98 |
+
|
| 99 |
+
If the type is complete and if deallocation function lookup finds both a
|
| 100 |
+
usual deallocation function with only a pointer parameter and a usual
|
| 101 |
+
deallocation function with both a pointer parameter and a size
|
| 102 |
+
parameter, then the selected deallocation function shall be the one with
|
| 103 |
+
two parameters. Otherwise, the selected deallocation function shall be
|
| 104 |
+
the function with one parameter.
|
| 105 |
+
|
| 106 |
+
When a *delete-expression* is executed, the selected deallocation
|
| 107 |
+
function shall be called with the address of the block of storage to be
|
| 108 |
+
reclaimed as its first argument and (if the two-parameter deallocation
|
| 109 |
+
function is used) the size of the block as its second argument.[^23]
|
| 110 |
|
| 111 |
Access and ambiguity control are done for both the deallocation function
|
| 112 |
and the destructor ([[class.dtor]], [[class.free]]).
|
| 113 |
|