Effective C++ 17. Store newed objects in smart pointers in standalone statements
来源:互联网 发布:软件 原型 设计 工具 编辑:程序博客网 时间:2024/06/14 16:28
int priority();void processWidget(std::tr1::shared_ptr<Widget> pw, int priority);
// it won't compile, tr1::shared_ptr constructor // taking a raw pointer is explicitprocessWidget(new Widget, priority());
processWidget(std::tr1::shared_ptr<Widget>(new Widget), priority());
the order of performing maybe
1. Execute “new Widget”.
2. Call priority.
3. Call the tr1::shared_ptr constructor.
If the call to priority yields an exception, the pointer returned from “new Widget” will be lost.
// Store newed objects in smart pointers in standalone statementsstd::tr1::shared_ptr<Widget> pw(new Widget);processWidget(pw, priority());
阅读全文
0 0
- Effective C++ 17. Store newed objects in smart pointers in standalone statements
- [翻译] Effective C++, 3rd Edition, Item 17: 在 standalone statements(独立语句)中将 new 出来的 objects(对象)存入 smart pointers(智能指针)
- Smart Pointers in Boost
- Smart Pointers in C++
- Lesson 2: If statements in C
- When should you store serialized objects in the database?
- C指针学习(Pointers in C)
- Function Pointers and Callbacks in C
- Why are pointers used in C++?
- Stack and Heap Objects in Objective-C
- ARC forbids Objective-C objects in struct
- ARC forbids Objective-C objects in struct
- ARC forbids Objective-C objects in struct
- ARC forbids Objective-C objects in struct
- ARC forbids Objective-C objects in struct
- ARC forbids Objective-C objects in struct
- ARC forbids Objective-C objects in struct
- ARC forbids Objective-C objects in struct
- MySQL 使用mysqld_multi部署单机多实例详细过程
- 在慕课学完javascript的入门课程总结
- ue4 renderTexture简单记录
- ServletContext作用功能详解
- php引用变量原理
- Effective C++ 17. Store newed objects in smart pointers in standalone statements
- Linux常用命令
- ITK笔记:SetRequestedRegion设置ROI无效,滤波器仍然处理了全图
- 集合中对象属性去重复,只保留一个属性值。
- 微信 Android 视频编码爬过的那些坑
- CentOS 7下安装Python3.5
- get.post请求乱码的问题
- 二维码生成秘籍
- Ubuntu14.04 Seetaface安装和测试