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

张家港外贸型网站制作如何优化关键词搜索排名

张家港外贸型网站制作,如何优化关键词搜索排名,网站如何让百度抓取,网页制作创建站点内容前言 有一节我们分析了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://www.wooajung.com/news/27366.html

相关文章:

  • 做网站除了域名还要买什么久久seo综合查询
  • 做58同城网站需要多少钱青岛seo整站优化公司
  • 谷歌做不做网站青岛网站建设公司排名
  • 河北住房建设厅网站首页经营管理培训课程
  • 部门网站建设需求确认表seo流程
  • 中山技术支持中山网站建设一手渠道推广平台
  • 建设春风摩托车官方网站百度seo关键词排名技术
  • 普通网站跟营销型网站的对比stp营销战略
  • 安徽招标投标信息网优化网站推广教程排名
  • 做彩票网站被捉将受到什么惩罚免费职业技能培训网站
  • 深圳建立网站公司google play下载安卓
  • 北京网站建设有哪些公司seo排名赚靠谱吗
  • 网站如何做软文推广购买友情链接网站
  • 网站开发如何运用form表单杭州10大软件开发公司
  • wordpress 更新页面大连seo关键词排名
  • 网站怎么做百度认证互联网营销软件
  • 动态做网站搜索引擎seo优化平台
  • 做网站的边框企业营销管理
  • wordpress完整备份珠海seo快速排名
  • 国家知识产权局商标注册杭州seo网络推广
  • 深圳 网站建设公免费接单平台
  • 武汉门户网站建设百度客服中心人工电话
  • 网站设计有什么前景制作网站免费
  • 258做网站靠谱么谷歌优化排名哪家强
  • 怎么看一个网站谁做的优化今日头条网页版入口
  • 交互网站建设上海关键词自动排名
  • android studio下载网站关键词优化排名公司
  • 网站seo信息隐藏seo搜索排名影响因素主要有
  • 石家庄网站建设备案怎样做好销售和客户交流
  • 环保网站设计价格nba最新交易