When a unique_ptr goes out of scope, its destructor runs automatically. The destructor calls delete on the managed pointer. You never write delete yourself. This works even with exceptions.
If code throws before reaching a manual delete, a raw pointer leaks. But unique_ptr's destructor runs during stack unwinding, so no leak occurs. Early returns, multiple exit points, complex control flow all become safe.
The unique_ptr guarantees cleanup no matter how the scope exits. Memory management becomes automatic.