Cpp Coding Standards/ERR/ExSpec

From Apache OpenOffice Wiki
< Cpp Coding Standards‎ | ERR
Revision as of 15:56, 22 May 2007 by Np (Talk | contribs)

Jump to: navigation, search

Avoid Exception Specifications

Id: ERR:ExSpec

Summary

Don't write exception specifications on your functions.

Explanation

Exception specifications often do not what they are expected to do. They add overhead to the runtime. If they are triggered, they immediately terminate the program, which is often not the wanted behaviour. Therefore todays C++ experts leave them out.

Exceptions

If you override a virtual function which has an exception specification in its base class, you need to do that in the overriding function, too - or to remove the exception specification in the base class. The exception specification in the overriding function needs to be at least as restrictive as the one in the base class (it has to list the same, or less exceptions than the base class function).

Personal tools