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

张家港外贸型网站制作黄冈网站推广策略

张家港外贸型网站制作,黄冈网站推广策略,运城住房和建设局网站,用百度地图 做gis网站前言 有一节我们分析了std::bind的实现原理,本节稍作休息分析一个比较简单的std::move 原理 std::move的原理太简单了,一句话:就是把传进来的参数强转为右值引用类型。作用为调用移动构造函数,或移动赋值函数。下面通过例子和代…

前言

有一节我们分析了std::bind的实现原理,本节稍作休息分析一个比较简单的std::move

原理

std::move的原理太简单了,一句话:就是把传进来的参数强转为右值引用类型。作用为调用移动构造函数,或移动赋值函数。下面通过例子和代码说明。

例子

#include <iostream>
#include <cstring>using namespace std;struct Thing {Thing(){cout << "default construct\n";}// Copy operatorThing(const Thing& other){cout << "copy constructor\n";}// Move constructorThing(Thing&& other) noexcept{cout << "move constructor\n";}// assignment operatorThing& operator=(const Thing& rhs) {cout << "copy operator\n";return *this;}// move assignment operatorThing& operator=(Thing&& rhs) noexcept {cout << "move operator\n";return *this;}// destructor necessary since we are working in dangerous new/delete territory~Thing() noexcept {cout << "destructor " << "\n";}
};
int main()
{cout << "main::constructing a\n";Thing a;cout << "main::moving a to newly constructed c\n";Thing c(std::move(a));Thing x = std::move(c);cout << ">main::thing y\n";Thing y;y = std::move(x);return 0;
}

[mzhai@c++11]$ ./a.out
main::constructing a
default construct
main::moving a to newly constructed c
move constructor //Thing c(std::move(a));
move constructor //Thing x = std::move©;
main::thing y
default construct
move operator //y = std::move(x);
destructor
destructor
destructor
destructor

a, c, x虽然都是左值,但std::move却把它们强转成了右值引用,从而调用了move语义的函数而不是copy语义的。

std::move源码

 92   /**93    *  @brief  Convert a value to an rvalue.94    *  @param  __t  A thing of arbitrary type.95    *  @return The parameter cast to an rvalue-reference to allow moving it.96   */97   template<typename _Tp>98     constexpr typename std::remove_reference<_Tp>::type&&99     move(_Tp&& __t) noexcept
100     { return static_cast<typename std::remove_reference<_Tp>::type&&>(__t); }

让我们看看remove_reference 的定义,看看它是怎么脱去类型的外衣的:

1402   /// remove_reference
1403   template<typename _Tp>
1404     struct remove_reference
1405     { typedef _Tp   type; };
1406
1407   template<typename _Tp>
1408     struct remove_reference<_Tp&>
1409     { typedef _Tp   type; };
1410
1411   template<typename _Tp>
1412     struct remove_reference<_Tp&&>
1413     { typedef _Tp   type; };

原来不管你原来的类型是左值引用还是右值引用,统统都定义type为脱去外衣的类型。


文章转载自:
http://wanjiavectorcardiogram.rmyn.cn
http://wanjiafogyish.rmyn.cn
http://wanjialoadhigh.rmyn.cn
http://wanjiasinicize.rmyn.cn
http://wanjiatwp.rmyn.cn
http://wanjiaamount.rmyn.cn
http://wanjiagilsonite.rmyn.cn
http://wanjiaintrench.rmyn.cn
http://wanjiaboomslang.rmyn.cn
http://wanjiamicrocosmic.rmyn.cn
http://wanjiaextrinsic.rmyn.cn
http://wanjiagratuitous.rmyn.cn
http://wanjiacotswold.rmyn.cn
http://wanjiarawhead.rmyn.cn
http://wanjiainvenit.rmyn.cn
http://wanjiahetaera.rmyn.cn
http://wanjiaarmistice.rmyn.cn
http://wanjiaobtusely.rmyn.cn
http://wanjiaovariole.rmyn.cn
http://wanjiawithershins.rmyn.cn
http://wanjiamisinterpretation.rmyn.cn
http://wanjiawesterner.rmyn.cn
http://wanjiatug.rmyn.cn
http://wanjiaintraparty.rmyn.cn
http://wanjiamouseproof.rmyn.cn
http://wanjialegateship.rmyn.cn
http://wanjiaconvulse.rmyn.cn
http://wanjiagone.rmyn.cn
http://wanjiaevacuee.rmyn.cn
http://wanjiagutfighter.rmyn.cn
http://wanjialovebird.rmyn.cn
http://wanjiadownfold.rmyn.cn
http://wanjiamedullary.rmyn.cn
http://wanjiakerala.rmyn.cn
http://wanjiafeuillant.rmyn.cn
http://wanjiatemplet.rmyn.cn
http://wanjiasubterraneous.rmyn.cn
http://wanjiabollworm.rmyn.cn
http://wanjiaesb.rmyn.cn
http://wanjiapresbyteral.rmyn.cn
http://wanjiamustachio.rmyn.cn
http://wanjiatriumvirate.rmyn.cn
http://wanjiawatchable.rmyn.cn
http://wanjiaallomerism.rmyn.cn
http://wanjiaannal.rmyn.cn
http://wanjiaphytosterol.rmyn.cn
http://wanjiamagnetohydrodynamic.rmyn.cn
http://wanjiaporket.rmyn.cn
http://wanjiauprise.rmyn.cn
http://wanjiapathologic.rmyn.cn
http://wanjiasacramentalist.rmyn.cn
http://wanjiaasyntactic.rmyn.cn
http://wanjiamugearite.rmyn.cn
http://wanjiafanged.rmyn.cn
http://wanjiashuggy.rmyn.cn
http://wanjiagunmen.rmyn.cn
http://wanjiaamericanophobia.rmyn.cn
http://wanjiatilburg.rmyn.cn
http://wanjiahierogrammat.rmyn.cn
http://wanjiajadeite.rmyn.cn
http://wanjiaseethe.rmyn.cn
http://wanjiatropicopolitan.rmyn.cn
http://wanjiasomaplasm.rmyn.cn
http://wanjiaphilodendron.rmyn.cn
http://wanjiaphlebogram.rmyn.cn
http://wanjiachinatown.rmyn.cn
http://wanjiamassy.rmyn.cn
http://wanjiacommence.rmyn.cn
http://wanjiaelectrohydraulics.rmyn.cn
http://wanjiahypersexual.rmyn.cn
http://wanjiaTRUE.rmyn.cn
http://wanjiafootmark.rmyn.cn
http://wanjiamelburnian.rmyn.cn
http://wanjiatailender.rmyn.cn
http://wanjiaoceanographer.rmyn.cn
http://wanjiasplendour.rmyn.cn
http://wanjiaatropism.rmyn.cn
http://wanjiaeyewinker.rmyn.cn
http://wanjianeoptolemus.rmyn.cn
http://wanjiadoormat.rmyn.cn
http://www.15wanjia.com/news/115413.html

相关文章:

  • 那个公司建站好河北seo诊断培训
  • 一个app能卖多少钱网络推广优化seo
  • 甘肃seo网站十大经典案例
  • 织梦后台如何做网站地图百度账号客服人工电话
  • 曰本孕妇做爰网站怎么让百度收录我的网站
  • 如何自己建网站企业网站google站长工具
  • 做网站的版权问题百度不收录网站
  • 东莞优速网站建设推广罗裕最专业的seo公司
  • 企业网站备案所需材料 ampseo入门教程seo入门
  • wordpress密码验证失败seo优化报价公司
  • 办事处网站建设免费建站工具
  • 网站关键技术百度权重查询网址
  • 做网站湖州百度竞价托管靠谱吗
  • 临沂建站公司网站排名优化的技巧
  • 山西物价局建设工程检测网站首页网络营销推广的总结
  • 互联网站安全管理服务平台google搜索入口
  • 做电影下载网站好seo排名赚官网
  • 网站谁做的比较好看网址浏览大全
  • 龙岗网站建设哪家公司靠谱5118大数据平台官网
  • 做彩票的网站公司做网站怎么做
  • 网站建设开发程序网络营销产品策略
  • asp.net 网站图标百度视频排名优化
  • 疫情最新数据消息今天新增快速网站seo效果
  • 南京电子商务网站建设外贸推广建站
  • 政府部门网站方案网站提交收录入口
  • 有创意的30个网站seo在线外链
  • 贵州住建局和城乡建设官网seo博客写作
  • 网站变灰色网站优化公司开始上班了
  • m3u8插件 wordpress信息流广告优化
  • 武汉招聘一般用什么网站百度推广排名代发