c++协程4 (boost::coroutine)

来源:互联网 发布:二端电阻网络的无源性 编辑:程序博客网 时间:2024/06/07 18:03
#include <stdexcept>#include <iostream>#include <boost/coroutine/all.hpp>using boost::coroutines::coroutine;void cooperative(coroutine<void>::push_type &sink){//返回mainsink();throw std::runtime_error("error");}int main(){coroutine<void>::pull_type source{ cooperative };try{//调用cooperativesource();//捕获抛出的异常std::runtime_error}catch (const std::runtime_error &e){std::cerr << e.what() << '\n';}}

0 0