Last active
August 28, 2024 16:23
-
-
Save slyshykO/fdb1d9c3a7c54b4b837ffe4f526c59f9 to your computer and use it in GitHub Desktop.
RAII for file
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
#include <memory> | |
int main() | |
{ | |
std::unique_ptr<std::FILE, decltype(&std::fclose)> f(std::fopen(name.c_str(), "r"), &std::fclose); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment