Re: How on earth did noexcept get through the standards process?
On 13 Apr., 10:01, Alexander Terekhov wrote:
SG wrote:
[...]
reason not to enforce static checking. Maybe I'm missing something. If
so, please comment.
One reason not to enforce static checking is not to repeat the Java's
mistake.
See http://www.mindview.net/Etc/Discussions/CheckedExceptions
Do the same arguments apply to the noexcept(bool) exception
specification? I don't think so. noexcept is only about the question
whether a function may throw or promises not to throw and not about
the exception object types.
But I actually don't like the proposed escape hatch "noexcept-
block" (see N2855). It would force us to create a new block. Variables
defined in that block will quickly cease to exist if you make these
blocks small. But small noexcept-blocks are desirable if one wants to
utilize the static checking and only disable it very locally.
Brainstorming: What about an optional static checking (QoI) where only
warnings are produced and programs not rejected? Then, we would only
need an escape hatch to turn off the warning. This could be done via
attributes:
double sqrt(double); // throws exception for negative numbers
void f(double x) noexcept {
if (x > 0) {
x = sqrt[[assumenoexcept]](x);
}
}
I think, this could be added to a later (post C++11) revision without
effects on backwards compatibility. Opinions?
Cheers!
SG
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]