Re: Exception specifications unfortunate, and what about their future?
On 21 Nov., 20:51, Patrik Kahari <patrik.kah...@googlemail.com> wrote:
The only exception for my refusal to love checked exception would
be the strict no-throw guarantee - this is a quite important one
and a compiler taking advantage of such beast can easily optimize
the code.
I think sutter mentions it in the same book. But the no throw
specification cant really be used by the compiler to optimize code. It
infact carries a performance penalty, because for every function with
a nothrow specifier the compiler has to enforce at runtime that no
exception leaks out of the function. It basically has to enclose the
whole function with a catch(...) and terminate (threw std::unexpected
()) if it catches anything. Not very useful.
I'm not talking about throw() as specified today, I
was envisioning a reasonable use-case for a statically
checked exception specification - let's name it as
"throw() static" or some such. This envision would
*not* use a runtime check, but all inner function
calls would recursively need to fulfill the same
"throw() static" to make the code well-formed.
Greetings from Bremen,
Daniel Kr?gler
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]