How to catch a throw; ?

I know it seems odd, and indeed it is and I would never do it, but I am just curious:
1
2
3
4
5
try
{
	throw;
}
//How do I catch that? 


It is valid C++ and compiles fine, and even runs fine, throwing an exception and terminating because it doesn't get caught. But my questions is, how do I catch a thrown exception that didn't throw any value, as in the above code? Just a curiosity. ;)
Like this:
1
2
3
4
5
try {
        throw;
} catch (...) {
        std::cerr << "ROH NO!" << std::endl;
}
Since no exception is being thrown, you cannot catch anything.

The Standard wrote:
15.1.8 If no exception is presently being handled, executing a throw-expression with no operand calls std::terminate() (15.5.1).

Ahh, thanks. I understand now. :)
Topic archived. No new replies allowed.