Universal References in C++11(&&)

关于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.
posted @ 2020-03-18 14:55  王月明  阅读(131)  评论(0)    收藏  举报