当前位置:网站首页>智能指针笔记
智能指针笔记
2022-08-11 04:44:00 【Ingsuifon】
shared_pointer
Aliasing
shared_poiner 可以和另一个指针共享所有权,但是它实际指向的却是不同对象。
即拥有的对象和指向的对象不是同一物。
//aliasing constructor
template<class Y>
shared_ptr(const shared_ptr<Y>& r, element_type* ptr) noexcept;
class Foo {
public:
Foo(int value) : m_data {
value} {
}
int m_data;
};
auto foo {
make_shared<Foo>(42) };
auto aliasing {
shared_ptr<int> {
foo, &foo->m_data } };
//aliasing和foo共同拥有对Foo对象的所有权,但aliasing指向的是它的成员变量
边栏推荐
- 如何进行AI业务诊断,快速识别降本提效增长点?
- 洛谷P4061 大吉大利,晚上吃鸡
- map and set - natural search and lookup semantics
- 澳大利亚网络空间安全体系建设论析
- Redis:解决分布式高并发修改同一个Key的问题
- Use Navicat Premium to export database table structure information to Excel
- leetcode 9. 回文数
- About the pom.xml file
- 破解事务性工作瓶颈,君子签电子合同释放HR“源动力”!
- Mysql: set the primary key to automatically increase the starting value
猜你喜欢

快速使用UE4制作”大场景游戏“

交换机和路由器技术-35-NAT转PAT

交换机和路由器技术-30-标准ACL

Layered Architecture & SOA Architecture

Self-research capability was recognized again, and Tencent Cloud Database was included in the Forrester Translytical report

洛谷P2150 寿司晚宴

对象的创建以及显示转换

0 Basic software test for career change, self-study for 3 months, 12k*13 salary offer

Overview of the JVM garbage collection and mechanism

交换机和路由器技术-31-扩展ACL
随机推荐
交换机和路由器技术-36-端口镜像
分层架构&SOA架构
剑指offer_抽象建模能力
The principle, architecture, implementation, practice of "transfer" and "search", no need to be afraid of interviews
视觉任务种常用的类别文件之一json文件
交换机和路由器技术-30-标准ACL
CAN/以太网转换器 CAN与以太网互联互通
I wrote some code in my resume, but I still can't pass the interview
Harvesting of radio frequency energy
"239 Sliding Window Maximum Value" on the 16th day of LeetCode brushing
关于pom.xml文件
交换机和路由器技术-35-NAT转PAT
解决多线程调用sql存储过程问题
Apache初体验
[Server installation mysql] Use mysql offline installation package to install mysql5.7 under centos7
交换机和路由器技术-32-命名ACL
es-head plugin insert query and conditional query (5)
To break the bottleneck of transactional work, the gentleman signs the electronic contract to release the "source power" of HR!
每日一题-滑动窗口
梅克尔工作室--OpenEuler培训笔记(1)