int main() { auto l = std::list<double>(10); std::generate(std::begin(l), std::end(l), make_generator(l)); for (auto const& i : l) { std::cout << i << " "; } return 0; }
int main() { auto fibonacci = [ current = 0, first = 0, second = 1 ]() mutable { current = first + second; first = second; second = current; return current; }; auto sqr = [](int x) { return x * x; }; auto func = [&]() { return sqr(fibonacci()); }; auto gen = make_generator(func); for (int i = 0; i < 10; ++i) { std::cout << *(++gen) << std::endl; } }