Vektorenaddition



  • 5.3.5 Delete [expr.delete]
    1 The delete-expression operator destroys a most derived object (1.8) or array created by a new-expression.
    delete-expression:
    ::opt delete cast-expression


    The first alternative is for non-array objects, and the second is for arrays. The operand shall have a pointer
    type, or a class type having a single conversion function (12.3.2) to a pointer type. The result has type
    void.
    2 If the operand has a class type, the operand is converted to a pointer type by calling the above-mentioned
    conversion function, and the converted operand is used in place of the original operand for the remainder of
    this section. In either alternative, if the value of the operand of delete is the null pointer the operation
    has no effect. In the first alternative (delete object), the value of the operand of delete shall be a pointer
    to a non-array object or a pointer to a sub-object (1.8) representing a base class of such an object (clause
    10). If not, the behavior is undefined. In the second alternative (delete array), the value of the operand of
    delete shall be the pointer value which resulted from a previous array new-expression.72) If not, the
    behavior is undefined. [Note: this means that the syntax of the delete-expression must match the type of the
    object allocated by new, not the syntax of the new-expression. ] [Note: a pointer to a const type can be
    the operand of a delete-expression; it is not necessary to cast away the constness (5.2.11) of the pointer
    expression before it is used as the operand of the delete-expression. ]
    3 In the first alternative (delete object), if the static type of the operand is different from its dynamic type, the
    static type shall be a base class of the operand’s dynamic type and the static type shall have a virtual
    destructor or the behavior is undefined. In the second alternative (delete array) if the dynamic type of the
    object to be deleted differs from its static type, the behavior is undefined.73)
    4 The cast-expression in a delete-expression shall be evaluated exactly once. If the delete-expression calls
    the implementation deallocation function (3.7.3.2), and if the operand of the delete expression is not the
    null pointer constant, the deallocation function will deallocate the storage referenced by the pointer thus
    rendering the pointer invalid. [Note: the value of a pointer that refers to deallocated storage is indeterminate.]
    5 If the object being deleted has incomplete class type at the point of deletion and the complete class has a
    non-trivial destructor or a deallocation function, the behavior is undefined.
    6 The delete-expression will invoke the destructor (if any) for the object or the elements of the array being
    deleted. In the case of an array, the elements will be destroyed in order of decreasing address (that is, in
    reverse order of the completion of their constructor; see 12.6.2).
    7 The delete-expression will call a deallocation function (3.7.3.2).
    8 [Note: An implementation provides default definitions of the
    global deallocation functions
    operator delete() for non-arrays (18.4.1.1) and operator delete[]() for arrays (18.4.1.2).
    A C + + program can provide alternative definitions of these functions (17.4.3.4), and/or class-specific versions
    (12.5). ] When the keyword delete in a delete-expression is preceded by the unary :: operator, the
    global deallocation function is used to deallocate the storage.
    9 Access and ambiguity control are done for both the deallocation function and th destructor (12.4, 12.5).


Anmelden zum Antworten