Re: Exception Specifications
On May 2, 11:14 pm, Martin York <Martin.YorkAma...@gmail.com> wrote:
On May 2, 3:49 am, Erik Wikstr=F6m <Erik-wikst...@telia.com> wrote:
On 2008-05-02 11:37, Keith Halligan wrote:
On May 2, 9:53 am, Rolf Magnus <ramag...@t-online.de> wrote:
std::unexpected() should be called, which in turn calls the unexpecte=
d
handler, which by default (if you didn't specify another one) calls
std::terminate, which calls the terminate handler, which by default c=
alls
abort().
The spec does mention this alright, I modified the code to make use of=
them on Linux and yes I can alter how the termination works via
std::set_unexpected() and std::set_terminate() functions, to stop the
abort from occurring.
So with this in mind then Visual C++ is incorrect in following the
spec.
Yes, VS only supports the empty (nothrow) exception specifier.
Exception specifications is one of those ideas that did not really
work.
It works fine for me.
The problem is that it has been explained in a way that leads
people to believe it does something that it doesn't, and which
in fact isn't possible. What it does do is implement a very
small part of programming by contract; you contract NOT to throw
any exceptions other than the ones listed, and the compiler
generates code to enforce that contract. (In practice, of
course, the only really useful contract in this case is no
exceptions.)
The generally except way of using them is not to use them (with the
exception of no throw).
Which is a major exception.
The last thing (in most situations) you actually want your
application to do is terminate with extreme prejudice.
If there is a violation of the contract, that's exactly what you
want to happen. If the program is not working correctly, it is
important for it to terminate as quickly as possible, with as
much prejudice as possible, so the system can take whatever
steps are necessary in such cases.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34