auto keyword does not work as a type for function arguments, in C++11. If you don’t want to use the actual type in lambda functions, then you could use the code below.
for_each(begin(v), end(v), [](decltype(*begin(v)) it ){
foo( it + 5);
});
The code in the question works just fine in C++ 14.