首页 > 编程语言 > 详细

C++11 Universal Reference

时间:2018-06-08 16:31:11      阅读:174      评论:0      收藏:0      [点我收藏+]

 

Q1. 什么是universal reference?

If a variable or parameter is declared to have type T&& for some deduced type T, that variable or parameter is a universal reference.

 

Q2. 什么是deduced typeT?

A2. Template parameter、auto declaration, ect.

 

Q3. universal reference 是什么类型?

  • If the expression initializing a universal reference is an lvalue, the universal reference becomes an lvalue reference.
  • If the expression initializing the universal reference is an rvalue, the universal reference becomes an rvalue reference.

Q4. 什么是lvalue(左值),什么是rvalue(右值)? 

The C++11 standard generally specifies whether an expression is an lvalue or an rvalue on a case-by-case basis

  通常可以这么归纳:

  • If you can take the address of an expression, the expression is an lvalue.
  • If the type of an expression is an lvalue reference (e.g., T& or const T&, etc.), that expression is an lvalue. 
  • 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 are also rvalues.

 

C++11 Universal Reference

原文:https://www.cnblogs.com/wangpei0522/p/9156275.html

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