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

花木企业网站源码餐厅设计

花木企业网站源码,餐厅设计,上海网站 建设,做外贸要建什么网站前言 有一节我们分析了std::bind的实现原理#xff0c;本节稍作休息分析一个比较简单的std::move 原理 std::move的原理太简单了#xff0c;一句话#xff1a;就是把传进来的参数强转为右值引用类型。作用为调用移动构造函数#xff0c;或移动赋值函数。下面通过例子和代…前言 有一节我们分析了std::bind的实现原理本节稍作休息分析一个比较简单的std::move 原理 std::move的原理太简单了一句话就是把传进来的参数强转为右值引用类型。作用为调用移动构造函数或移动赋值函数。下面通过例子和代码说明。 例子 #include iostream #include cstringusing 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; }[mzhaic11]$ ./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 templatetypename _Tp98 constexpr typename std::remove_reference_Tp::type99 move(_Tp __t) noexcept 100 { return static_casttypename std::remove_reference_Tp::type(__t); }让我们看看remove_reference 的定义看看它是怎么脱去类型的外衣的 1402 /// remove_reference 1403 templatetypename _Tp 1404 struct remove_reference 1405 { typedef _Tp type; }; 1406 1407 templatetypename _Tp 1408 struct remove_reference_Tp 1409 { typedef _Tp type; }; 1410 1411 templatetypename _Tp 1412 struct remove_reference_Tp 1413 { typedef _Tp type; };原来不管你原来的类型是左值引用还是右值引用统统都定义type为脱去外衣的类型。
http://www.w-s-a.com/news/625167/

相关文章:

  • 大连网站优化技术长沙高端网站建设服务
  • 郎创网站建设做的网站 v2ex
  • 广东网站建设教程江西城乡住房建设网站
  • 做ppt卖给网站wordpress insert
  • 文化传媒公司网站模板wordpress转typecho
  • 网站建设设计视频郑州 服装网站建设
  • 网站建设什么公司好织梦cms默认密码
  • 大型网站 空间网上商城官网入口
  • 成都全美网站建设江苏专业网站建设
  • 足球网站模板有帮忙做阿里巴巴网站的吗
  • 建设厅报名网站京东网站的建设与发展前景
  • 金寨县住房和城乡建设部网站网页作业怎么做一个网站
  • 做ppt模板网站有哪些内容wap是什么意思卡老师
  • 网站建设一定要域名吗网站后台关键词设置
  • 标书制作公司网站坪山网站建设哪家便宜
  • 防止做网站的人修改数值门户网站架构
  • 电子项目外包网站考二建需要什么学历和专业
  • 做网站推广引流效果好吗电商推广技巧
  • 亦庄网站建设价格广州网站推广服务
  • 十大免费ppt网站下载重庆在线高校平台登录
  • 做环保网站案例百度seo教程
  • 体育用品网站模板网站建设话术
  • 潍坊网站建设服务商做网站多久能盈利
  • 嘉定区做网站房产信息查询官网
  • 网站直播间 是怎么做的唐山论坛建站模板
  • 深圳洲聚网站建设wordpress 泛解析
  • 五金东莞网站建设技术支持wordpress 添加模板
  • 网站申请专利春节网页设计素材
  • 进网站备案md风格的wordpress主题
  • 如何建站网站十大免费建站app