Created
September 19, 2016 08:30
-
-
Save zhangyuchi/b8cb5e703b70686f12c1575259230a89 to your computer and use it in GitHub Desktop.
自动关闭文件 raii From http://www.viva64.com/en/b/0429/#ID0E3ZEM
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
auto deleter = [](FILE* f) {fclose(f);}; | |
std::unique_ptr<FILE, decltype(deleter)> p(fopen("1.txt", "w"), | |
deleter); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment