首页 > 编程语言 > 详细

Universal References in C++11(&&)

时间:2020-03-18 15:40:34      阅读:49      评论:0      收藏:0      [点我收藏+]

关于c++11中的右值引用,这篇文章讲得清晰透彻。涵盖左值与右值的定义,type deductionauto&&以及指定类型的&&和模板参数T&&。讲解了什么情况下&&是universal reference, rvlue reference。(??)

对于写程序来说,以下左右值定义足够:

  1. If you can take the address of an expression, the expression is an lvalue.
  2. If the type of an expression is an lvalue reference (e.g., T& or const T&, etc.), that expression is an lvalue.
  3. Otherwise, the expression is an rvalue. Conceptually (and typically also in fact), rvalues correspond to temporary objects, such as those returned from functions or created through implicit type conversions. Most literal values (e.g., 10 and 5.3) are also rvalues.

Universal References in C++11(&&)

原文:https://www.cnblogs.com/codemeta-2020/p/12517408.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!