//main.cpp
#include <iostream>
#include <utility>
int main()
{
auto fib = [i = 0, j = 1]() mutable {
i = std::exchange(j, j + i);
return i;
};
for(int i = 0; i < 10; ++i)
{
std::cout << fib() << " ";
}
}
//output
1 1 2 3 5 8 13 21 34 55