Stay Hungry , Stay Foolish

君子生非异也,善假于物也

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

随笔分类 -  C/C++进阶

C/C++深入特性,源码解读,代码优化等
摘要:使用场景 当类对象被shared_ptr管理时,需要在类自己定义的函数中把当前对象作为参数传递给其他函数时,必须传递一个shared_ptr,否则就不能保持shared_ptr管理这个类对象的语义。因为有一个raw pointer指向这个类对象,而shared_ptr对类对象的这个引用没有计数,很可能shared_ptr已经把类对象资源释放了,而那个调用函数还在使用类对象--显然,这肯定会... 阅读全文
posted @ 2016-11-02 15:35 octocat 阅读(272) 评论(0) 推荐(0)

摘要:#include template struct TraitsHelper { static const bool isPointer = false; }; template struct TraitsHelper { static const bool isPointer = true; }; template class Test { public: ... 阅读全文
posted @ 2016-08-15 14:33 octocat 阅读(193) 评论(0) 推荐(0)