Cpp Coding Standards/ERR/ExSpec

From Apache OpenOffice Wiki
Jump to: navigation, search

Avoid Exception Specifications (ExSpec)


Don't write exception specifications on your functions.


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.


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