Hacker News new | ask | show | jobs
by smallstepforman 2 days ago
The unique_ptr destructor is called on scope exit, and there are times you want this earlier before other critical code.
2 comments

That's why you can define your own scope to control that.
you can call release or reset as needed if you want the delete to happen early - and if you forget an obscure code path it still gets deleted on scope exit which is probably good enough for that path.