Skip to content

Instantly share code, notes, and snippets.

@Danielmelody
Last active December 7, 2020 08:08
Show Gist options
  • Save Danielmelody/2be8e21ee9ec895fa204d4afd3c86662 to your computer and use it in GitHub Desktop.
Save Danielmelody/2be8e21ee9ec895fa204d4afd3c86662 to your computer and use it in GitHub Desktop.
RAII cleaner in one line
{
// resources are easy to gain by capture, and use in the destructor
std::shared_ptr<int> cleaner(nullptr, [some_captures](int *) { do_something(); });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment