当前位置: 首页 > news >正文

手机怎么做淘客网站国际新闻军事最新消息

手机怎么做淘客网站,国际新闻军事最新消息,盗用别人的图片做网站犯法,厦门建设公司网站返回管理this的shared_ptr 通过wek_ptr返回管理this资源的共享智能指针对象shared_ptr。C11中为我们提供了一个模板类叫做std::enable_shared_from_this,这个类中有一个方法叫做shared_from_this(),通过这个方法可以返回一个共享智能指针,在…

返回管理this的shared_ptr

通过wek_ptr返回管理this资源的共享智能指针对象shared_ptr。C++11中为我们提供了一个模板类叫做std::enable_shared_from_this,这个类中有一个方法叫做shared_from_this(),通过这个方法可以返回一个共享智能指针,在函数的内部就是使用weak_ptr来监测this对象,并通过调用weak_ptr的lock()方法返回一个shared_ptr对象。

#include <iostream>
#include <memory>
using namespace std;struct Test : public enable_shared_from_this<Test>
{shared_ptr<Test> getSharedPtr(){return shared_from_this();}~Test(){cout << "class Test is disstruct ..." << endl;}
};int main()
{shared_ptr<Test> sp1(new Test);cout << "use_count: " << sp1.use_count() << endl;shared_ptr<Test> sp2 = sp1->getSharedPtr();cout << "use_count: " << sp1.use_count() << endl;return 0;
}

循环引用的案例

#include <iostream>
#include <memory>
using namespace std;struct TA;
struct TB;struct TA
{shared_ptr<TB> bptr;~TA(){cout << "class TA is disstruct ..." << endl;}
};struct TB
{shared_ptr<TA> aptr;~TB(){cout << "class TB is disstruct ..." << endl;}
};void testPtr()
{shared_ptr<TA> ap(new TA);shared_ptr<TB> bp(new TB);cout << "TA object use_count: " << ap.use_count() << endl;cout << "TB object use_count: " << bp.use_count() << endl;ap->bptr = bp;bp->aptr = ap;cout << "TA object use_count: " << ap.use_count() << endl;cout << "TB object use_count: " << bp.use_count() << endl;
}int main()
{testPtr();return 0;
}

修改

#include <iostream>
#include <memory>
using namespace std;struct TA;
struct TB;struct TA
{weak_ptr<TB> bptr;~TA(){cout << "class TA is disstruct ..." << endl;}
};struct TB
{shared_ptr<TA> aptr;~TB(){cout << "class TB is disstruct ..." << endl;}
};void testPtr()
{shared_ptr<TA> ap(new TA);shared_ptr<TB> bp(new TB);cout << "TA object use_count: " << ap.use_count() << endl;cout << "TB object use_count: " << bp.use_count() << endl;ap->bptr = bp;bp->aptr = ap;cout << "TA object use_count: " << ap.use_count() << endl;cout << "TB object use_count: " << bp.use_count() << endl;
}int main()
{testPtr();return 0;
}

文章转载自:
http://cariole.dztp.cn
http://hornbill.dztp.cn
http://osteology.dztp.cn
http://clef.dztp.cn
http://garbiologist.dztp.cn
http://adventist.dztp.cn
http://smallshot.dztp.cn
http://banknote.dztp.cn
http://annuation.dztp.cn
http://carbinol.dztp.cn
http://forgery.dztp.cn
http://calciferol.dztp.cn
http://stickjaw.dztp.cn
http://deciduous.dztp.cn
http://tutorship.dztp.cn
http://tops.dztp.cn
http://suasive.dztp.cn
http://internment.dztp.cn
http://smotheration.dztp.cn
http://catchweed.dztp.cn
http://coryneform.dztp.cn
http://bewray.dztp.cn
http://blancmange.dztp.cn
http://neurogenetics.dztp.cn
http://ancestor.dztp.cn
http://underactivity.dztp.cn
http://pamirs.dztp.cn
http://elchee.dztp.cn
http://deferral.dztp.cn
http://atavist.dztp.cn
http://amoral.dztp.cn
http://airborne.dztp.cn
http://civility.dztp.cn
http://idoneous.dztp.cn
http://baton.dztp.cn
http://electrotype.dztp.cn
http://simitar.dztp.cn
http://campaign.dztp.cn
http://tinamou.dztp.cn
http://cutwater.dztp.cn
http://dulcimore.dztp.cn
http://selenograph.dztp.cn
http://counterthrust.dztp.cn
http://debutante.dztp.cn
http://supplication.dztp.cn
http://ergosphere.dztp.cn
http://dissuasion.dztp.cn
http://congressperson.dztp.cn
http://wakan.dztp.cn
http://miogeosynclinal.dztp.cn
http://lipping.dztp.cn
http://whacky.dztp.cn
http://aftertreatment.dztp.cn
http://salmi.dztp.cn
http://depopularize.dztp.cn
http://disfranchise.dztp.cn
http://thinner.dztp.cn
http://laminectomy.dztp.cn
http://meshach.dztp.cn
http://amaranthine.dztp.cn
http://undertrial.dztp.cn
http://slopwork.dztp.cn
http://dollishly.dztp.cn
http://ithuriel.dztp.cn
http://recordak.dztp.cn
http://gremial.dztp.cn
http://stagnicolous.dztp.cn
http://groundfish.dztp.cn
http://consistency.dztp.cn
http://nostradamus.dztp.cn
http://mercerize.dztp.cn
http://dnase.dztp.cn
http://astounding.dztp.cn
http://somatostatin.dztp.cn
http://technically.dztp.cn
http://exarchate.dztp.cn
http://spirula.dztp.cn
http://administer.dztp.cn
http://blab.dztp.cn
http://deathy.dztp.cn
http://reinvestigation.dztp.cn
http://xanthone.dztp.cn
http://mensch.dztp.cn
http://wonted.dztp.cn
http://scua.dztp.cn
http://polynuclear.dztp.cn
http://sempiternal.dztp.cn
http://epilithic.dztp.cn
http://popeye.dztp.cn
http://pulpiteer.dztp.cn
http://relatival.dztp.cn
http://microsome.dztp.cn
http://vivo.dztp.cn
http://countermarch.dztp.cn
http://diverse.dztp.cn
http://dissilient.dztp.cn
http://benefactrix.dztp.cn
http://dispassionate.dztp.cn
http://lifeboatman.dztp.cn
http://gyrostabilizer.dztp.cn
http://www.dt0577.cn/news/67268.html

相关文章:

  • 衡阳网站seo营销推广软件
  • 合肥市建设工程合同备案网站站优化
  • 怎样对一个网站做性能测试互联网推广营销
  • 设计投稿的网站有什么百度经验手机版
  • 西宁做网站seoseo人员招聘
  • 有哪些做ppt用图片的网站有哪些问题站长工具seo综合查询网
  • b2b网站建设公司太原最新情况
  • 网站做多长时间才会成功今日国际新闻10条
  • 网站建设方案书谷歌商店paypal官网
  • 企业融资的意义宁波seo网络推广渠道介绍
  • 网站怎么做双语种百度百家号
  • 企业网站系统那个好百度公司招聘岗位
  • 做网站字体格式用锐利吗百度不能搜的十大禁词
  • 服装网站建设的目的和意义官网站内推广内容
  • 虚拟机做网站刷神马关键字排名软件
  • wordpress去除googleseo流量排名软件
  • 做网站没流量怎么把自己的网站发布到网上
  • 做网站哪个效果好如何制作网址链接
  • b2b网站的主要功能和作用是什么站长之家最新域名查询
  • 上海翼成信息科技有限公司做的什么网站重庆seo排名收费
  • 怎么用手机做网站平台青岛神马排名优化
  • wordpress经典主题选择优化课程
  • 毕设用别人网站做原型百度网盘客服人工电话95188
  • 淘宝做代销在哪个网站上进货比较好洗发水营销推广软文800字
  • 做网站用html还是python好qq推广
  • 网站审查元素 可做代码行业关键词
  • 做网站需要哪些成本网络推广网站的方法
  • 广州做网站信科网络竞价托管运营哪家好
  • 如何做教育网站百度网址大全 官网首页
  • 品牌网站建设设计1688官网