Quote:
The main problems with exception specifications are that they're only "sort of" part of the type system, they don't do what most people think, and you almost always don't want what they actually do.
...
They cause the compiler to inject additional run-time overhead in the form of implicit try/catch blocks around the function body to enforce via run-time checking that the function does in fact emit only listed exceptions (possibly none), unless the compiler can statically prove that the exception specification can never be violated in which case it is free to optimize the checking away. And exception specifications can both enable and prevent further compiler optimizations (beside the inherent overhead already described); for example, some compilers refuse to inline functions that have exception specifications.
Worst of all, however, is that exception specifications are a blunt instrument: When violated, by default they immediately terminate your program. You can register an unexpected_handler, but it's highly unlikely to help you much because you get exactly one global handler and the only way the only way the handler could avoid immediately calling terminate would be to rethrow an exeption that is permissible, but [it's hard to see how the handler could] know what exeptions might be legal without trivializing exception specifications altogether.
...
[BoostLRG]'s experience is that a throws-nothing exceptio specification (i.e., throw()) on a non-inline function "may have some benefit with some compilers." Not a stunning endorsement from one of the most highly regarded and expertly designed C++ library projects in the world.