使用C++11新特性来实现RAII进行资源管理
摘要:方法一:借助auto、decltype、unique_ptr、Lambda表达式构造 sqlite3 *db = NULL; auto deleter = [](sqlite3 *pdb){sqlite3_close(pdb);} int nRet = sqlite3_open16(L"F:\\my.db",&db); std::unique_ptr pdb(db,d...
阅读全文
posted @
2014-07-10 11:15
qinfengxiaoyue
阅读(537)
推荐(0)
C++ 11: function & bind 使用示例
摘要:#include #include struct Foo { Foo(int num) : num_(num) {} void print_add(int i) const { std::cout f_display = print_num; f_display(-9); // store a lambda std::function f_display_42 ...
阅读全文
posted @
2014-05-07 11:16
qinfengxiaoyue
阅读(3051)
推荐(0)