// Naive version of throwing a non-local exception from a coroutine. // There are better ways... #include using namespace std; struct E {}; _Coroutine C { bool error; void main() { try { error = false; throw E(); } catch( E ) { error = true; } // catch } // main public: void mem() { resume(); if ( error ) throw E(); } // mem }; int main() { C c; try { c.mem(); } catch( E ) { cout << "caught E" << endl; } // catch } // main