On 16/03/2015 16:28, Paul wrote:
> Accelerated c++ contains the code below which is discussed for the
> case n = 0. If n = 0, I can see that v is an empty vector but I don't
> see what effect the delete statement has. The delete statement
> deletes the iterator one past the end of an empty vector. This seems
> similar to deleting a null pointer but is not quite the same. I would
> think that the delete statement does nothing in the same way that
> deleting a null pointer does nothing. However, I can't find anything
> that explicitly says so. Thank you.
> T* p = new T[n]; delete[] p;
If I remember well, if n = 0, by standard p cannot be nullptr, but
delete should be safe. You should have a look at the standard for the
exact wording.