1.auto_ptr

这个所谓的只能指针有点鸡肋!  没有引用计数,而且还有一个所有权转移的情况!

当所有权转移后,以前的auto_ptr将会成为null

2.shared_ptr

增加了引用计数,没有所有权转移问题

但是它俩在析构的时候都没有delete[]动作,所以不能释放数组类型!

当然,可以重写一个可以释放数组的模板类!

C++ 之 auto_ptr and shared_ptr的更多相关文章

  1. 初次窥见智能指针auto_ptr和shared_ptr

    #include <memory>//shared_ptr要用的头文件 using namespace std; class A //测试auto_ptr和shared_ptr的delet ...

  2. stl中auto_ptr,unique_ptr,shared_ptr,weak_ptr四种智能指针使用总结

    stl中auto_ptr,unique_ptr,shared_ptr,weak_ptr四种智能指针使用总结 1. auto_ptrauto_ptr主要是用来解决资源自动释放的问题,比如如下代码:voi ...

  3. auto_ptr与shared_ptr ZZ

    http://blog.csdn.net/rogeryi/article/details/1442700 Part(1) 这篇文章试图说明如何使用auto_ptr和shared_ptr,从而使得动态分 ...

  4. auto_ptr, unique_ptr, shared_ptr and weak_ptr智能指针讲解

    笔者介绍:姜雪伟,IT公司技术合伙人,IT高级讲师,CSDN社区专家,特邀编辑,畅销书作者,已出版书籍:<手把手教你架构3D游戏引擎>电子工业出版社和<Unity3D实战核心技术详解 ...

  5. auto_ptr和shared_ptr

    <Effective C++>在资源管理一节提到了智能指针,智能指针中最著名的当属auto_ptr和shared_ptr.本文主要研究两者的实现. auto_ptr的实现: templat ...

  6. C++ 智能指针 auto_ptr 和 shared_ptr

    首先,如果你不知道什么是智能指针,请先移步:C++智能指针简单剖析 1.auto_ptr #ifndef AUTO_PTR_H #define AUTO_PTR_H template<typen ...

  7. C++智能指针 auto_ptr、shared_ptr、weak_ptr和unique_ptr

    手写代码是理解C++的最好办法,以几个例子说明C++四个智能指针的用法,转载请注明出处. 一.auto_ptr auto_ptr这是C++98标准下的智能指针,现在常常已经被C++标准的其他智能指针取 ...

  8. 关于std:auto_ptr std:shared_ptr std:unique_ptr

    很多人听说过标准auto_ptr智能指针机制,但并不是每个人都天天使用它.这真是个遗憾,因为auto_ptr优雅地解决了C++设计和编码中常见的问题,正确地使用它可以生成健壮的代码.本文阐述了如何正确 ...

  9. <memory>(包括了auto_ptr,shared_ptr等各种指针)

    Memory elements This header defines general utilities to manage dynamic memory: Allocators allocator ...

随机推荐

  1. php操作redis简单例子

    <?php //在PHP里操作Redis //Redis就是php的一个功能类 //创建Redis对象 $redis = new Redis(); //链接redis服务器 $redis -&g ...

  2. angular 路由请求js文件

    <script type="text/javascript" src="http://apps.bdimg.com/libs/angular.js/1.3.2/an ...

  3. maven 使用

    1. download maven from http://maven.apache.org/ 2. unzip, setup MAVEN_HOME 3. change the configurati ...

  4. (48) odoo的button用法

    button 应用的比较多,这里来汇总一下 按钮<button>,支持的属性     icon  可用的icon在 addons/web/static/src/img/icons     ...

  5. ArcGIS Engine控件运行许可(转)

    ArcGIS Engine控件运行许可   Runtime绑定: 在ArcGIS Engine10.0中,许可方式发生了一定的变化,ArcGis10有一个新的要求---runtime绑定.就是在任何A ...

  6. 深入浅出Mybatis系列(六)---objectFactory、plugins、mappers简介与配置

    上篇文章<深入浅出Mybatis系列(五)---TypeHandler简介及配置(mybatis源码篇)>简单看了一下TypeHandler, 本次将结束对于mybatis的配置文件的学习 ...

  7. C#中图片与BASE64码互相转换

    //保存目录 string dir = "/upload/user/head"; //站点文件目录 string fileDir = HttpContext.Current.Ser ...

  8. 时间的处理 --java

    得到当天时间 SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd" ); String todayData = ...

  9. c#实现远程操作svn

    /// <summary> /// 本地svn服务器地址 /// </summary> private static string localSVN = Configurati ...

  10. Android Monkey 压力测试 介绍

    Monkey 是Android SDK提供的一个命令行工具, 可以简单,方便地运行在任何版本的Android模拟器和实体设备上. Monkey会发送伪随机的用户事件流,适合对app做压力测试 阅读目录 ...