Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL

Error Handling and Exceptions > Avoid exception specifications - Pg. 146

146 C++ Coding Standards 75. Avoid exception specifications. Summary Take exception to these specifications: Don't write exception specifications on your functions unless you're forced to (because other code you can't change has already introduced them; see Exceptions). Discussion In brief, don't bother with exception specifications. Even experts don't bother. 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. Exception specifications aren't part of a function's type, except when they are. They form a shadow type system whereby writing an exception specification is variously: Illegal: In a typedef for a pointer to function. Allowed: In the identical code without the typedef.