Created
August 24, 2014 12:39
-
-
Save yhliaoluan/7d938282127abbf560a9 to your computer and use it in GitHub Desktop.
Auto clean resource using unique_ptr
This file contains 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
int auto_clean() { | |
SOCKET socket = socket(AF_INET, SOCK_STREAM, 0); | |
unique_ptr<SOCKET, void (*)(SOCKET *)> ac(&socket, | |
[](SOCKET *s) { closesocket(*s); }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment