当前位置:网站首页>智能指针笔记
智能指针笔记
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指向的是它的成员变量
边栏推荐
猜你喜欢
随机推荐
交换机和路由器技术-36-端口镜像
Selenium自动化测试框架工作原理你明白了吗?
二叉堆的基础~
如何将360全景图导出高清短视频分享到视频平台上?
ALSA音频架构
Common layout effect realization scheme
【yolov7系列三】实战从0构建训练自己的数据集
交换机和路由器技术-32-命名ACL
梅克尔工作室--OpenEuler培训笔记(1)
What is machine learning?Explain machine learning concepts in detail
如何给网页添加icon图标?
Mysql:设置主键自动增长起始值
Jetson Orin platform 4-16 channel GMSL2/GSML1 camera acquisition kit recommended
监听U盘插入 拔出 消息,获得U盘盘符
Overview of the JVM garbage collection and mechanism
交换机和路由器技术-28-OSPF的NSSA区域
Mysql: set the primary key to automatically increase the starting value
【Web3 系列开发教程——创建你的第一个 NFT(9)】如何在手机钱包里查看你的 NFT
The sword refers to offer_abstract modeling capabilities
干货:服务器网卡组技术原理与实践