1.variadic templates
void print(){
}
template<typename T,typename...Types>
void print(const T& firstArg, const Types& ...args) {
cout<<firstArg<<endl;
print(args...);
}
优先特化的函数,其次泛化
2.Space in template Expressions
//since C++11
vector<vector<int>>
//before
vector<vector<int> >
3.nullptr&std::nullptr_t
void f(int);
void f(void*);
f(0); //f(int)
f(NULL); //f(int) if NULL is 0,ambiguous otherwise
f(nullptr); //f(void*)
nullptr实现:
typedef decltype(nullptr) nullptr_t;
调用std::nullptr_t这个数据结构,在<cstdeef>里面
4.auto
5.Uniform Intialization
一致性初始化,避免原来多种多样的初始化
原理是调用ctor通过函数参数initializer_list<T>传入,initializer_list<T>背后有个array<T,n>。编译器每个容器都有这样的函参的ctor
6.initializer lists
背后有array支撑,该类的对象构造函数是通过浅拷贝来进行,不是深拷贝
7.Explicit for ctors taking more than one argument
8.range-based
for statement
编译器淡化
9.=default, =delete
10.Alias Template
11.template template parameter
跟上述10一样的语义