Using auto is especially useful where the type is pretty long and /or complicated expression.
原文的大意是,C++11中auto是用在一些类型比较长(写代码的时候懒得敲)或者类型比较复杂的时候。
例如:
在进行迭代的时候,类型比较长
vector<string> v;
auto pos = v.begin(); //pos此处的类型应为 vector<string>::iterator
C++11中的lambda函数使用的时候,类型很难推导
auto I = [](int x)->bool{
...,
}
//此处的I 为一个lambda类型