What happens, if somewhere inside the function, something throws an exception? Considering that we've allocated some memory with new, we must delete that, but if an exception is thrown, then the execution of the code will follow on the nearest catch block. So that means, that to ensure we do not leak memory, we have to make a local catch block, try to free all the memory allocated, then re-throw the exception.
This happens since raw pointers are not automatically freed, and thus can be quite cumbersome.
An example of how to do this is not offered, since it is not considered a good solution.
However, a curious reader may wonder. Clearly, we can associate this problem with many other things, such as writing some information to a file, or some like. Some operation that, if the function fails, must be rolled back. That is, undone. Surely smart pointers cannot be used for all these things? Well, yes and no. While smart pointers are indeed powerful, they cannot do everything. Discussion of exception safety is a topic of its own and is not the scope of this article. Instead, a curious reader is directed to reading about Boost.ScopeExit.