Despite the missing language features like RAII etc., setjmp/longjmp
is fundamentally different from the mechanism used for throwing/catching exceptions. These days, exceptions are handled using zero-cost approach where the overhead is encountered if and only if the exception is actually thrown, and otherwise there is no overhead. Since the assumption is that in a good application exception are not generally thrown, it is called a "zero cost". With setjmp/longjmp, you will be setting the jump point/context every time you "enter a try block". Therefore, there will be a lot of runtime overhead just to set the jump points. Back in a day, exceptions were implemented using setjmp/longjmp
(by compilers, with RAII and all other stuff that other people stated as "missing" — so you can see why their answers are not entirely correct), so in theory you can achieve the same, but it will be far worse in terms of performance. For more details on exception handling implementation please refer to Itanium C++ ABI: Exception Handling.