5.2 Smart Pointer(智能指针)

shared_ptr的aliasing构造函数,接受一个shared pointer和一个raw pointer。它允许你掌握一个事实:某对象拥有另一个对象。例如:

struct X
{
int a;
}; shared_ptr<X> px(new X);
shared_ptr<int> pi(px,&px->a);

weak_ptr是shared-ptr的帮手,用来共享但不拥有对象,它的use_count()返回的对象是被shared_ptr拥有的次数,而且weak_ptr可以为空->expired()结果是true;lock()会产出一个shared-ptr。

class unique_ptr继承auto_ptr(现已不被认可),可以release()(shared-ptr不可以release是因为可能有其他shared-ptr指向它对象)。

对array,unique_ptr提供偏特化版本,而不用定义自己的deleter。例如:

std::unique_ptr<std::string[]> up(new std::string[10]);

unique_ptr与shared_ptr的deleter接口不同,它必须指明deleter的类型作为第二个template实参。

5.3 数值的极值

书中的例子用到 cout << boolalpha;

boolalpha,函数名称,功能是把bool值显示为true或false。

 

The C++ Standard Library --- A Tutorial Reference 读书笔记的更多相关文章

  1. 《The Python Standard Library》——http模块阅读笔记1

    官方文档:https://docs.python.org/3.5/library/http.html 偷个懒,截图如下: 即,http客户端编程一般用urllib.request库(主要用于“在这复杂 ...

  2. 《The Python Standard Library》——http模块阅读笔记3

    http.cookies — HTTP state management http.cookies模块定义了一系列类来抽象cookies这个概念,一个HTTP状态管理机制.该模块支持string-on ...

  3. 《The Python Standard Library》——http模块阅读笔记2

    http.server是用来构建HTTP服务器(web服务器)的模块,定义了许多相关的类. 创建及运行服务器的代码一般为: def run(server_class=HTTPServer, handl ...

  4. [译]The Python Tutorial#11. Brief Tour of the Standard Library — Part II

    [译]The Python Tutorial#Brief Tour of the Standard Library - Part II 第二部分介绍更多满足专业编程需求的高级模块,这些模块在小型脚本中 ...

  5. [译]The Python Tutorial#10. Brief Tour of the Standard Library

    [译]The Python Tutorial#Brief Tour of the Standard Library 10.1 Operating System Interface os模块为与操作系统 ...

  6. Swift Standard Library Reference.pdf

    Swift Standard Library Reference.pdf 下载地址 http://download.csdn.net/detail/swifttrain/7446331 自己的Mark ...

  7. C++11新特性——The C++ standard library, 2nd Edition 笔记(一)

    前言 这是我阅读<The C++ standard library, 2nd Edition>所做读书笔记的第一篇.这个系列基本上会以一章一篇的节奏来写,少数以C++03为主的章节会和其它 ...

  8. Python Standard Library

    Python Standard Library "We'd like to pretend that 'Fredrik' is a role, but even hundreds of vo ...

  9. The Python Standard Library

    The Python Standard Library¶ While The Python Language Reference describes the exact syntax and sema ...

随机推荐

  1. HQL的语言

    HQL: 是Hibernate Query Language的缩写 1.HQL查询 特点: 与SQL相似,SQL中的语法基本上都可以直接使用 SQL查询的是表和表中的列而HQL查询的是对象或者对象中的 ...

  2. UIImageView属性

        1.Image 设置图片,默认显示 UIImageView *_imageView = [[UIImageViewalloc]init]; _imageView.image = [UIImag ...

  3. UIActivityIndicatorView

    1.    activityIndicatorViewStyle 设置指示器的样式 UIActivityIndicatorViewStyleWhiteLarge UIActivityIndicator ...

  4. VS2010 AlwaysCreate

    VS2010 解决方案里有两个工程,每次按F7编译都会链接一次.链接完成再按F7又会链接一次..... 提示: 正在创建“Debug\testb.unsuccessfulbuild”,因为已指定“Al ...

  5. ThinkPHP分页链接支持数组参数的办法

    这几天在用ThinkPHP做系统,搜索页有个数组参数提交 <input class="params_t" name="t[]" type="ch ...

  6. oracle导sql脚本

    在plsql里,新建命令窗口,输入如下命令 @d:\test.sql

  7. Java基础之创建窗口——使用网格布局管理器(TryGridLayout)

    控制台程序. 网格布局管理器可以在容器的矩形网格中布局组件. import javax.swing.*; import java.awt.*; import javax.swing.border.Et ...

  8. linux: centos设置ip以及连接外网

    注明:我使用的的使centos 7,所有文件名是ifcfg-enp0s3, 一. 设置虚拟机中linux的ip,使本地能连通虚拟机的linux系统 1>.进入本地windows的cmd,输入ip ...

  9. objective-c底层: runtime机制

    runtime是oc的真面目.oc底层的一套c语言API. unsigned int count; //获取属性列表 objc_property_t *propertyList = class_cop ...

  10. Android Support Font 安卓系统支持字体(配图)

    测试了一台安卓机器,发现所有字体显示都一样.