#include #include #include #include #include #include using namespace std; typedef boost::coroutines::coroutine routine_t; // The implementation routine of the coroutine. void xrange_impl(routine_t::caller_type& yield, int limit) { for(int i = 0; i < limit; i++) { yield(i); // return results back to the caller } } int main() { routine_t foo(boost::bind(xrange_impl, _1, 10000)); return 0; };