Last active
December 7, 2020 08:08
-
-
Save Danielmelody/2be8e21ee9ec895fa204d4afd3c86662 to your computer and use it in GitHub Desktop.
RAII cleaner in one line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// 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