The for (auto x : collection)
iteration syntax is way cool I think... it literally cuts down the size of many loop headers by a factor of 4 or more (iterator types are often ... verbose)!
It also means you don't have to dereference the iterator in the body of the loop (with a traditional iterator loop, you always have to use *i
or i->...
to get the value of the element, but here you can just use x
), which in some cases makes the code look much nicer.