Re: exception specifications in the standard library
on Tue Apr 10 2007, "Robster" <rob_marion1-AT-yahoo.com> wrote:
On the other hand, I have read that exception
specifications may incur overhead regardless of
whether an exception is thrown. It is unclear to me
why that may be the case.
There are a lot of myths and half-truths floating around out there
about exception handling.
Furthermore, the use of
throw( ) with virtual functions would restrict derived
classes from throwing, and thus create a less
extensible design.
True.
The following was Stroustrup's reply:
I don't use exception specifications. They seemed a good idea at the
time, but have been a failure in every language that had them. In C++,
the problem is avoidable run-time overheads. For a historical and
somewhat less negative discussion, see "The Design and Evolution of
C++".
I disagree with Bjarne about the reason for their failure in C++.
They don't need to have any associated runtime overhead, and in some
cases -- if used *really* carefully and thoroughly -- can even reduce
runtime cost. The real problem is that they were given semantics that
are worse-than-useless in most cases. I'm not going to rehash the
details, as they've been hashed on this list many times over already.
I suggest you refer to the archives.
--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
Don't Miss BoostCon 2007! ==> http://www.boostcon.com
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]