#include<cstdlib>
#include<iostream>
#include<boost/coroutine2/all.hpp>
int main()
{
boost::coroutines2::coroutine<int>::pull_type source(
[](boost::coroutines2::coroutine<int>::push_type &sink){
int first = 1,second = 1;
sink(first);
sink(second);
for(int i = 0; i < 8; ++i){
int third = first + second;
second = third;
sink(third);
}
});
for(auto i : source){
std::cout << i << " ";
}
std::cout << "\nDone" << std::endl;
return EXIT_SUCCESS;
}
boost coroutine2 fibonacci.cpp
最新推荐文章于 2024-04-24 13:41:04 发布