// Cross a Try Statement with a Termination Handler #include #include #include #include using namespace std::chrono; struct NotRaisedException : public std::exception {}; int main(int argc, char * argv[]) { unsigned int times = 1; volatile bool should_throw = false; if (1 < argc) { times = strtol(argv[1], nullptr, 10); } time_point start_time = steady_clock::now(); for (unsigned int count = 0 ; count < times ; ++count) { try { asm volatile ("# try block"); if (should_throw) { throw NotRaisedException(); } } catch (NotRaisedException &) { asm volatile ("# catch block"); } } time_point end_time = steady_clock::now(); nanoseconds duration = duration_cast(end_time - start_time); std::cout << "Run-Time (ns): " << duration.count() << std::endl; }