C++11 Universal Reference

Source: Internet
Author: User

Q1. What is universal reference?

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

Q2. What is deduced Typet?

A2. Template parameter, Auto declaration, ect.

Q3. What is the type of 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 a rvalue, the universal reference becomes an rvalue reference.

Q4. What is Lvalue (lvalue) and what is rvalue (right value)?

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

This can usually be summed up as:

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

C++11 Universal Reference

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.