Removal of zero indicator
-
What happens when you try to remove a zero indicator through
delete
?
-
It's nothing.
Formal reference https://ru.stackoverflow.com/q/417797/10105 §5.3.5/2:
In the first alternative (delete object), the value of the operand of delete may be a null pointer value, a pointer to a non-array object created by a previous new-expression, or a pointer to a subobject (1.8) representing a base class of such an object (Clause 10). [...] In the second alternative (delete array), the value of the operand of delete may be a null pointer value or a pointer value that resulted from a previous array new-expression.
Translation:
For the first option
delete object
), Operanda valuedelete
may be the value of null-indicatoran indicator on an object which is not a mass established with the assistance ofnew
or an indicator for an item (1.8), representing the base class of the object (see clause 10). [...] Second casedelete array
), Operanda value may be the value of null-indicator or the value of the indicator obtained by means ofnew
For masses.From https://isocpp.org/wiki/faq/freestore-mgmt#delete-handles-null :
I need to check.
null
beforedelete p
?No!
Language C++ guarantees that
delete p
Nothing to do ifp
Yes.null
♪