Boost logo

Boost Users :

Subject: Re: [Boost-users] C++ guru required!
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2012-02-27 03:34:11


On 27.02.2012 07:15, Nevin Liber wrote:
>
> When you specify what you mean by "not checked by the compiler", then
> we'll talk. :-) Until you do, it is trivial to poke holes in it. For
> instance:
>
> if (0)
> {
> Fire Fire Fire! (note: this line is NOT a C++ comment)
> if (ShouldTheIf0OnlyGoToTheFirstEndBraceItFinds())
> {
> }
> LaunchTheMissiles();
> if (0) {
> }
>
> Did you really mean to launch the missiles?
>
That's not Robert's obligation to answer, since the original static if
proposal leaves the details of this question open as well. (Note,
though, that Andrei said that at the very least, the parser would have
to ensure that the tokens are brace-balanced in the dead branch. There
is no sane way to parse the example you've just given.)

Robert's suggestion is just that "static if" can be replaced by "if" if
the compiler is simply required to act as if the "if" was a "static if"
if the condition is a constant expression.

I think this is feasible. I also think it obscures intent, which is why
I'm against it.

Sebastian


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net