C++11 Auto and Decltype keywords

Source: Internet
Author: User

Today Mayuyu to introduce two important keywords in c++11, namely Auto and decltype. In fact, in c++98, there is already the Auto keyword, but in c++98, auto represents the semantics of temporary variables, and in C++11 Auto represents the automatic type deduction, as follows


The Auto keyword can deduce the type of a variable from an expression, which greatly simplifies the programmer's work. And auto is the type deduction of variables at compile time, so there is no effect on the efficiency of the program, and auto does not affect the compilation speed too much, because the compile time itself is also deduced from the right side to determine whether to match the left side.

In addition, auto in the template programming also has a relatively good effect, can make the program more concise.

Let's move on to another important keyword, decltype. Use the following

Decltype is the type of the variable derived from the derivation of the variable.

More information:http://towriting.com/blog/2013/08/08/improved-type-inference-in-cpp11/

C++11 Auto and Decltype keywords

Related Article

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.