您的位置:首页 > 移动开发 > Objective-C

Use unique_ptr to RAII your file objects

2014-01-25 16:08 351 查看
auto file_closer = [](int* pfd) { close(*pfd); };

int fd = open("a.txt", O_WRONLY|O_CREAT, 0666);

unique_ptr<int, decltype(file_closer)> raii_fd (&fd, file_closer);

// using fd
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐