[Clam-devel] throw specifications
Dirk Griffioen
dirk.griffioen at barcelonamedia.org
Mon May 18 01:49:16 PDT 2009
Hi,
I'd like to make a small remark about the throw-specifiactions: I think
they should be avoided (and if possible, removed).
As Herb Sutter writes: http://www.gotw.ca/gotw/082.htm:
*4.* When is it worth it to write exception specifications on functions?
Why would you choose to write one, or why not?
In brief, don't bother. Even experts don't bother.
Slightly less briefly, the major issues are:
Exception specifications can cause surprising performance hits, for
example if the compiler turns off inlining for functions with
exception specifications.
A runtime unexpected() error is not always what you want to have
happen for the kinds of mistakes that exception specifications are
meant to catch.
You generally can't write useful exception specifications for
function templates anyway because you generally can't tell what the
types they operate on might throw.
For more, see for example the Boost exception specification rationale
available via http://www.gotw.ca/publications/xc++s/boost_es.htm (it
summarizes to "Don't!").
So would it be okay if I remove them as I see them?
Best, Dirk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.clam-project.org/pipermail/clam-devel-clam-project.org/attachments/20090518/1c3effeb/attachment.html>
More information about the clam-devel
mailing list