Comment

Comment by thrownaway2424

This is one of my favorite features of unique_ptr. It is an all-purpose way to make something happen at the end of scope without having to write a new struct and destructor. You don't even need the pointer at all since you can simply do:

  std::unique_ptr<void> finally(42, [](void* unused){ whatever });

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton