zoukankan      html  css  js  c++  java
  • C++11 Universal Reference

    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语言字符编码处理
    Linux gperf命令
    C语言命令行处理
    深入分析Java ClassLoader原理
    微软Build2016:Xamarin杂记
    Ubuntu下配置Tomcat以指定(非root)身份执行
    Android之弹出多级菜单
    OC基础:Date
    Linux IO 多路复用是什么意思?
    c语言实现输出一个数的每一位
  • 原文地址:https://www.cnblogs.com/wangpei0522/p/9156275.html
Copyright © 2011-2022 走看看