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