#include <algorithm> #include <ctime> #include <iostream> #include <conio.h> #include <stdio.h> #include <setjmp.h> using namespace std; struct J { jmp_buf buff; }; struct backer { J j; mutable bool did; backer(int v):did(v) { } backer(backer const& o):j(o.j),did(o.did) { o.did = true; } ~backer() { if(!did) { longjmp(j.buff, 1); } } operator bool() { return !did; } }; int main() { if(backer b = setjmp(b.j.buff)) { cout << "IF Block executed.\n"; } else { cout << "ELSE Block executed."; } _getch(); return 0; }