#include #include #include #include #include using Coro = boost::coroutines::coroutine; class TestRAII { public: TestRAII (void) {std::cout << "TestRAII::ctor" << std::endl;} ~TestRAII (void) {std::cout << "TestRAII::dtor" << std::endl;} }; class worker { public: void fn(Coro::pull_type &aSink) { TestRAII testRaii; std::cout << "coro call 1" << std::endl; aSink(); std::cout << "coro call 2" << std::endl; aSink(); std::cout << "coro call 3" << std::endl; } }; int main(int /*argc*/, char** /*argv*/) { worker w; auto* coro = new Coro::push_type(boost::bind(&worker::fn, &w, _1)); std::cout << "main: before coro call..." << std::endl; (*coro)(); std::cout << "main: after coro call..." << std::endl; delete coro; std::cout << "main: after coro delete..." << std::endl; return 0; }