The C++ Standard Library --- A Tutorial Reference 读书笔记
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 读书笔记的更多相关文章
- 《The Python Standard Library》——http模块阅读笔记1
官方文档:https://docs.python.org/3.5/library/http.html 偷个懒,截图如下: 即,http客户端编程一般用urllib.request库(主要用于“在这复杂 ...
- 《The Python Standard Library》——http模块阅读笔记3
http.cookies — HTTP state management http.cookies模块定义了一系列类来抽象cookies这个概念,一个HTTP状态管理机制.该模块支持string-on ...
- 《The Python Standard Library》——http模块阅读笔记2
http.server是用来构建HTTP服务器(web服务器)的模块,定义了许多相关的类. 创建及运行服务器的代码一般为: def run(server_class=HTTPServer, handl ...
- [译]The Python Tutorial#11. Brief Tour of the Standard Library — Part II
[译]The Python Tutorial#Brief Tour of the Standard Library - Part II 第二部分介绍更多满足专业编程需求的高级模块,这些模块在小型脚本中 ...
- [译]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模块为与操作系统 ...
- Swift Standard Library Reference.pdf
Swift Standard Library Reference.pdf 下载地址 http://download.csdn.net/detail/swifttrain/7446331 自己的Mark ...
- C++11新特性——The C++ standard library, 2nd Edition 笔记(一)
前言 这是我阅读<The C++ standard library, 2nd Edition>所做读书笔记的第一篇.这个系列基本上会以一章一篇的节奏来写,少数以C++03为主的章节会和其它 ...
- Python Standard Library
Python Standard Library "We'd like to pretend that 'Fredrik' is a role, but even hundreds of vo ...
- The Python Standard Library
The Python Standard Library¶ While The Python Language Reference describes the exact syntax and sema ...
随机推荐
- iOS 快递查询
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @pr ...
- 使用mysql 的docker
sudo docker run --name phpmyAdmin3 --link some-mysql:mysql -d phpmyadmin/phpmyadmin:latest -p 8080:8 ...
- 11G中自动收集统计信息
在11G中,引入了一个名为 gather_stats_prog 的自动运行任务专用于自动收集统计信息.其对应的客户端名称为"auto optimizer stats collection&q ...
- 学习OpenCV——粒子滤波(网上两篇文章总结)
粒子滤波的理论实在是太美妙了,用一组不同权重的随机状态来逼近复杂的概率密度函数.其再非线性.非高斯系统中具有优良的特性.opencv给出了一个实现,但是没有给出范例,学习过程中发现网络上也找不到.le ...
- [原创]java WEB学习笔记70:Struts2 学习之路-- 输入验证,声明式验证,声明是验证原理
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
- [转]Chrome 控制台console的用法
Chrome 控制台console的用法 下面我们来看看console里面具体提供了哪些方法可以供我们平时调试时使用. 目前控制台方法和属性有: ["$$", "$x&q ...
- PHP-字符串过长不用担心
字符串过长可以用定界符: >>>GOD ................巨长务必的字符串 GOD;
- hdu5314 Happy King
树分治. 代码 #pragma comment(linker, "/STACK:102400000,102400000") #include<cstdio> #incl ...
- 实验一 操作系统模仿cmd
实验一.命令解释程序的编写 专业:商软(2)班 姓名:王俊杰 学号:201406114252 一. 实验目的 (1)掌握命令解释程序的原理: (2)掌握简单的DOS调用方法: (3 ...
- 夺命雷公狗—angularjs—21—解决angularjs压缩问题
我们在实际的开发中往往离不开js的代码压缩,因为这样可以减轻服务器的压力,是的的方法如下所示: <!DOCTYPE html> <html lang="en" n ...