Exception Specifications

John Love-Jensen eljay@adobe.com
Wed Dec 6 15:21:00 GMT 2006


Hi Perry,

I only use "no throw" specification, i.e., throw(), on functions that
absolutely guarantee that they do not throw.  And I use it sparingly, only
on my functions that really shouldn't throw, ever, such as swap functions,
and I know (a priori) that those functions will never throw.

NOTE:  I have been stung by writing a "no throw" function, annotated with
throw(), and even commented in the contract comments, yet someone later put
in some additional "helpful" tracing/debugging facilities that did throw in
some situations... no joy in Mudville.  Caveat emptor.

I do not put itemized throw specifications on functions.

I highly recommend C++ Coding Standards by Sutter and Alexandrescu, in
particular the section on Error Handling and Exceptions.

Moreso, I highly recommend all of Sutter's books on C++.

Sincerely,
--Eljay



More information about the Gcc-help mailing list