#include #include #include #include #include using namespace std; class Task : private boost::noncopyable { private: typedef boost::coroutines2::coroutine Coro; typedef Coro::pull_type CoroPull; typedef Coro::push_type CoroPush; public: CoroPull * m_yield; CoroPush m_coro; Task(std::function const & entryPoint) : m_yield(nullptr), m_coro([this, entryPoint] (CoroPull & myYield) { m_yield = &myYield; entryPoint(); }) {} }; void printer(void) { cout << "hello" << endl; } int main(void) { Task mytask(&printer); mytask.m_coro(); return 0; }