using static for designing better closure

Until now when designing a closure with lambda-expressions in C++ I was doing the following :

std::vector v;
int n{0};
v.reserve(1000);
std::generate_n(std::back_inserter(v), 1000, [&](){return n++;});

Someone just made me realised that we can use the static keyword inside for adding a local static variable as in :

std::vector v;
v.reserve(1000);
std::generate_n(std::back_inserter(v), 1000, [&](){static int n = 0; return n++;});

More concise:)