本文共 410 字,大约阅读时间需要 1 分钟。
#include#include #include using boost::coroutines::coroutine;void cooperative(coroutine ::push_type &sink){ //返回main sink(); throw std::runtime_error("error");}int main(){ coroutine ::pull_type source{ cooperative }; try { //调用cooperative source(); //捕获抛出的异常std::runtime_error } catch (const std::runtime_error &e) { std::cerr << e.what() << '\n'; }}