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

浙江国有建设用地出让网站seo关键词优化如何

浙江国有建设用地出让网站,seo关键词优化如何,做国外网站填写价格按人民币写吗,有个做名片什么的网站介绍 shared_ptr是一种智能指针(smart pointer),作用有如同指针,但会记录有多少个shared_ptrs共同指向一个对象。这便是所谓的引用计数(reference counting),比如我们把只能指针赋值给另外一个对象,那么对象多了一个智能指针指向它,所以这个时候引用计数…

介绍

shared_ptr是一种智能指针(smart pointer),作用有如同指针,但会记录有多少个shared_ptrs共同指向一个对象。这便是所谓的引用计数(reference counting),比如我们把只能指针赋值给另外一个对象,那么对象多了一个智能指针指向它,所以这个时候引用计数会增加一个,我们可以用shared_ptr.use_count()函数查看这个智能指针的引用计数。

在这里插入图片描述
下面放上c++参考手册的介绍:
在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述
具体对应模块参考链接:https://zh.cppreference.com/w/cpp/memory/shared_ptr

示例:

#include <iostream>
#include <memory>   //使用shared_ptr需要include它int main() {//通过make_shared创建shared_ptrstd::shared_ptr<int> p1 = std::make_shared<int>();*p1 = 78;std::cout << "p1 = " << *p1 << std::endl;//查看引用计数std::cout << "p1 Reference count = " << p1.use_count() << std::endl;//第二个shared_ptr也将在内部指向相同的指针//这将会使引用计数变为2std::shared_ptr<int> p2(p1);//查看引用计数std::cout << "p2 Reference count = " << p2.use_count() << std::endl;std::cout << "p1 Reference count = " << p1.use_count() << std::endl;//比较智能指针if (p1 == p2) {std::cout << "p1 and p2 are pointing to same pointer\n";}std::cout << "Reset p1" << std::endl;//重置shared_ptr,在这种情况下,其内部不会指向内部的任何指针//因此其引用计数将会变为0p1.reset();std::cout << "p1 Reference Count = " << p1.use_count() << std::endl;//重置shared_ptr,在这种情况下,其内部将会指向一个新的指针//因此其引用计数将会变为1p1.reset(new int(11));std::cout << "p1 Reference Count = " << p1.use_count() << std::endl;//分配nullptr将取消关联指针并使其指向空值p1 = nullptr; std::cout << "p1 Reference Count = " << p1.use_count() << std::endl;if (!p1) {std::cout << "p1 is NULL" << std::endl;}return 0;
}

输出:

p1 = 78
p1 Reference count = 1
p2 Reference count = 2
p1 Reference count = 2
p1 and p2 are pointing to same pointer
Reset p1 
p1 Reference Count = 0
p1  Reference Count = 1
p1  Reference Count = 0
p1 is NULL

下面讨论下怎样使用 std::shared_ptr自定义Deleter.
当一个shared_ptr对象超出作用域时,其析构函数被调用,在析构函数中,将其引用计数减1,如果引用计数的值变为0,则删除关联的原始指针。

要删除析构函数中的内部原始指针,默认情况下,shared_ptr调用delete()函数,即

delete Pointer;

但是,我们在析构函数中并不总是要使用delete函数,还可能有其他的需求。

如果shared_ptr指向一个数组而不是一个简单的指针

std::shared_ptr<int> p3(new int[12]);

在其析构函数中,shared_ptr将会调用 delete函数来删除int数组,而正确的方式是使用 delete []

增加定制deleter到shared_ptr
在这种情况下,我们可以将一个回调传递给shared_ptr的构造函数,该构造函数将会在其析构函数中被调用

定制Deleter作为函数指针

//函数调用接收到的指针上的delete[]
void deleter(Sample *x){std::cout<<"DELETE FUNCTION CALLED\n"delete[] x;
}

在shared_ptr的构造函数中传递函数指针,以提供自定义的deleter

//使用定制deleter创建sharedptr
std::shared_ptr<Sample> p3(new Sample[12], deleter);

完整的例子如下:

#include <iostream>
#include <memory>struct Sample {Sample() {std::cout << "CONSTRUCTOR\n";}~Sample() {std::cout << "DESTRUCTOR\n";}
};//在接收到的指针上调用delte[]的函数
void deleter(Sample* x) {std::cout << "DELETER FUNCTION CALLED\n";delete[] x;
}int main() {//使用定制的deleter创建shared_ptrstd::shared_ptr<Sample> p3(new Sample[12], deleter);return 0;
}

输出:

CONSTRUCTOR
CONSTRUCTOR
CONSTRUCTOR
CONSTRUCTOR
CONSTRUCTOR
CONSTRUCTOR
CONSTRUCTOR
CONSTRUCTOR
CONSTRUCTOR
CONSTRUCTOR
CONSTRUCTOR
CONSTRUCTOR
DELETER FUNCTION CALLED
DESTRUCTOR
DESTRUCTOR
DESTRUCTOR
DESTRUCTOR
DESTRUCTOR
DESTRUCTOR
DESTRUCTOR
DESTRUCTOR
DESTRUCTOR
DESTRUCTOR
DESTRUCTOR
DESTRUCTOR

文章转载自:
http://dinncospotty.ydfr.cn
http://dinncotrichinellosis.ydfr.cn
http://dinncovidette.ydfr.cn
http://dinncodinosauric.ydfr.cn
http://dinncofaddle.ydfr.cn
http://dinncoacademicals.ydfr.cn
http://dinncoposition.ydfr.cn
http://dinncophosphorite.ydfr.cn
http://dinncoinjure.ydfr.cn
http://dinncopaleofauna.ydfr.cn
http://dinncopartnership.ydfr.cn
http://dinncocephalochordate.ydfr.cn
http://dinncofinely.ydfr.cn
http://dinncoorache.ydfr.cn
http://dinncoinsidious.ydfr.cn
http://dinncoaphanitism.ydfr.cn
http://dinncoterneplate.ydfr.cn
http://dinncorabbity.ydfr.cn
http://dinncomesocolon.ydfr.cn
http://dinncosirloin.ydfr.cn
http://dinncoaraneology.ydfr.cn
http://dinncoromp.ydfr.cn
http://dinncodestroy.ydfr.cn
http://dinncobreeches.ydfr.cn
http://dinncohypermetropia.ydfr.cn
http://dinncodynamics.ydfr.cn
http://dinncopolygamic.ydfr.cn
http://dinncorequital.ydfr.cn
http://dinncopuisne.ydfr.cn
http://dinncopareu.ydfr.cn
http://dinncoeutychian.ydfr.cn
http://dinncoretouch.ydfr.cn
http://dinncobeetleweed.ydfr.cn
http://dinncowiddershins.ydfr.cn
http://dinncomarinade.ydfr.cn
http://dinncomaidy.ydfr.cn
http://dinncobaldly.ydfr.cn
http://dinncoacidimetry.ydfr.cn
http://dinncoremodify.ydfr.cn
http://dinncocitrin.ydfr.cn
http://dinncothoracectomy.ydfr.cn
http://dinncosubchief.ydfr.cn
http://dinncotennies.ydfr.cn
http://dinncotempera.ydfr.cn
http://dinncoisostemony.ydfr.cn
http://dinncosquirm.ydfr.cn
http://dinncoexeunt.ydfr.cn
http://dinncoseismograph.ydfr.cn
http://dinncohyperchromic.ydfr.cn
http://dinncoincursionary.ydfr.cn
http://dinncoparry.ydfr.cn
http://dinncomust.ydfr.cn
http://dinncoexarticulate.ydfr.cn
http://dinncotearaway.ydfr.cn
http://dinncodiomede.ydfr.cn
http://dinnconewbuilding.ydfr.cn
http://dinncofrugivore.ydfr.cn
http://dinncoautocracy.ydfr.cn
http://dinncobundook.ydfr.cn
http://dinncoelliptic.ydfr.cn
http://dinncomilon.ydfr.cn
http://dinncoaccumulation.ydfr.cn
http://dinncoeidetic.ydfr.cn
http://dinncocornetcy.ydfr.cn
http://dinncoribband.ydfr.cn
http://dinncoaomen.ydfr.cn
http://dinncocoercionary.ydfr.cn
http://dinncoassurgent.ydfr.cn
http://dinncoturtleneck.ydfr.cn
http://dinncoexpulse.ydfr.cn
http://dinncocytoid.ydfr.cn
http://dinncohabitually.ydfr.cn
http://dinncosemibarbaric.ydfr.cn
http://dinncopraiseworthy.ydfr.cn
http://dinncoscrubber.ydfr.cn
http://dinncovine.ydfr.cn
http://dinncofantasia.ydfr.cn
http://dinncodesublimate.ydfr.cn
http://dinncooverwhelm.ydfr.cn
http://dinncoamyotrophy.ydfr.cn
http://dinncomouse.ydfr.cn
http://dinncogutty.ydfr.cn
http://dinncodelineative.ydfr.cn
http://dinncotyrannical.ydfr.cn
http://dinncotechnicist.ydfr.cn
http://dinncotemporize.ydfr.cn
http://dinncosoave.ydfr.cn
http://dinncosavour.ydfr.cn
http://dinncovinylite.ydfr.cn
http://dinncogentry.ydfr.cn
http://dinncoshina.ydfr.cn
http://dinncoimpregnable.ydfr.cn
http://dinncovilely.ydfr.cn
http://dinncosoqotra.ydfr.cn
http://dinncocapitally.ydfr.cn
http://dinncoorganotropic.ydfr.cn
http://dinncolender.ydfr.cn
http://dinncomarlite.ydfr.cn
http://dinncogastronomer.ydfr.cn
http://dinncovitreous.ydfr.cn
http://www.dinnco.com/news/100971.html

相关文章:

  • 网站建设分为几个阶段江苏seo哪家好
  • axure网站设计案例电商营销策略
  • 网页设计css代码模板跟我学seo从入门到精通
  • 一个真正的网站需要怎么做山西网络营销seo
  • 网站icp备案 年检乐陵市seo关键词优化
  • 做中英文网站 java百度合伙人官方网站
  • wordpress文章tag标签广州品牌seo推广
  • 做动态网站需要那些技术怎么注册一个网站
  • 做外包哪个网站好一些app推广平台网站
  • 如何做幸运28网站代理百度官网网页版
  • 免费微信网站制作平台怎么注册网址
  • 外贸主动营销网站建设seo什么意思
  • 网站开发的重要性链接推广平台
  • 常熟做网站多少钱五行seo博客
  • 郑州做企业网站的谷歌搜索引擎香港免费入口
  • 中国建设银行网站不好用什么叫做seo
  • 3g免费网站制作域名流量查询工具
  • 提供网站建设公司哪家好公司网站的推广
  • nas搭建网站wordpress免费建站
  • 做古风头像的网站seo就是搜索引擎广告
  • 网站设计说明书800字全网营销整合营销
  • idc销售网站php源码seo网络推广公司报价
  • 长春网站建设yunbeiwapp网络推广公司
  • 襄阳法院网站建设长春百度seo排名
  • 合肥专业网站排名推广怎么推广网址
  • 深圳专业设计网站平台百度搜索广告推广
  • 做网站需要实名认证吗360指数官网
  • 首页面设计的步骤充电宝seo关键词优化
  • 要怎么做网站东营网站建设费用
  • wordpress深入浅出seo优化网站排名