(1)auto关键字和decltype关键字
在C++11之前,auto关键字用来指定存储期。在新标准中,它的功能变为类型推断。C++11引入auto关键词与之前C语言的auto意义已经不一样了。这里的auto是修饰未知变量的类型,编译器会通过此变量的初始化自动推导变量的类型。
例如:auto x = 1;编译器会通过“1”值,推导出变量x是整型。但在C++11之前,采用auto关键字定义变量 i = x,会抛出“declaration with no type”错误,如下:
更新为C++11标准之后,auto关键字能够声明并定义变量类型(自动推导)
#include<iostream> #include<typeinfo> suing namespace std; int main() { auto i = 1; auto j = 1.5; auto k = true; auto m = ‘c‘; auto n = "abcd"; cout<<typeid(i).name<<endl; cout<<typeid(j).name<<endl; cout<<typeid(k).name<<endl; cout<<typeid(m).name<<endl; cout<<typeid(n).name<<endl; return 0; }
如果初始值是引用,如:
(2)defaulted and deleted functions
(3)final and override
(3)trailing return type
(4)rvalue references
(5)move constructors and move assignment operators
(6)scoped enums
(7)constexpr and literal types
(8)list initialization
(9)delegating and inherited constructors
(10)brace-or-equal initializers
(11)nullptr
(12)long long
(13)char16_t and char32_t
(14)type aliases
(15)variadic templates
(16)generalized (non-trivial) unions
(17)generalized PODs (trivial types and standard-layout types)
(18)Unicode string literals
(19)user-defined literals
(20)attributes
(21)lambda expressions
(22)noexcept specifier and noexcept operator
(23)alignof and alignas
(24)multithreaded memory model
(25)thread-local storage
(26)GC interface
(27)range-for (based on a Boost library)
(28)static_assert (based on a Boost library)
原文:https://www.cnblogs.com/JCpeng/p/14994370.html