- auto is much faster than other types when assigning the return value of a STL to it.
queue<int> q;
auto aaa = q.front(); //much faster
int aaa = q.front(); //slower
- when you use auto in for loop, if the element is int, you don’t need reference. But if it’s STL like vector, you’d better use reference.
for (auto& v : vectorOfvector)
for (auto i : vectorOfInt)