#include <string>
#include <fstream>
#include <memory>
#include <cstdio>

class FileDeleter
{
  private:
    std::string filename;
  public:
    FileDeleter(const std::string& fn)
    :filename(fn){}

    void operator()(std::ofstream* fp){
      fp->close();
      std::remove(filename.c_str());
    }
};

int main()
{
  std::shared_ptr<std::ofstream> fp(new std::ofstream("tmpfile.txt"),FileDeleter("tmpfile.txt"));
}

最新文章

  1. POJ 2752 Seek the Name, Seek the Fame [kmp]
  2. 编译可在Android上运行的qemu user mode
  3. (转)Silverlight控件关系理解
  4. Fiddler进行模拟Post提交json数据,总为null解决方式
  5. SPOJ371 Boxes(最小费用最大流)
  6. 人活着系列之平方数 分类: sdutOJ 2015-06-22 17:10 7人阅读 评论(0) 收藏
  7. 记一次web项目总结
  8. Windows下bmp文件格式
  9. 嵌入式开发软件环境:uboot、kernel、rootfs、data布局分析
  10. 触摸事件 Touch MotionEvent ACTION
  11. IOS通过PushSharp开源框架发送推送
  12. 生产环境中CentOS7部署NET Core应用程序
  13. 左倾堆(C#)
  14. 队列工厂之RedisMQ
  15. SQLServer之分离数据库
  16. [Swift]LeetCode326. 3的幂 | Power of Three
  17. Centos 7 搭建FTP详细配置步骤方法
  18. [SQL Server]无法创建 SSIS 运行时对象,请验证 DTS.dll 是否可用及是否已注册
  19. 【python】python性能分析--待完善
  20. HDU 1171 (01背包问题)

热门文章

  1. Computer Vision_33_SIFT:Evaluation of Interest Point Detectors——2000
  2. 一个基于TCP/IP的小项目,实现广播消息的功能。(超详细版)
  3. keil结合st-link使用SWO的两种调试方法笔记
  4. 洛谷P2114 起床困难综合症【位运算】【贪心】
  5. 6、Spring Boot 2.x 集成 MyBatis
  6. 组件化网页开发 / 步骤二 &#183; 2-11 jquery的ajax方法 以及下一章跨域没懂
  7. xShell终端中文乱码-解决方法
  8. git error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
  9. 031_检测 MySQL 服务是否存活
  10. 2018 Nowcoder Multi-University Training Contest 2