why is this flagged as poor style?
Steven Schveighoffer
schveiguy at gmail.com
Tue Sep 22 21:50:11 UTC 2020
On 9/22/20 5:35 PM, Andrei Alexandrescu wrote:
> The style checker for phobos flags this code:
>
> static if (!is(typeof(unaryFun!fun(r.front)) == Flag!"each"))
> cast(void) unaryFun!fun(r.front);
> else
> if (unaryFun!fun(r.front) == No.each) return No.each;
>
> with "Mismatched static if. Use 'else static if' here."
>
> But in fact the intention is to execute a run-time `if` on the `else`
> branch of the `static if`.
>
> Is this worth fixing?
>
I think it needs braces (I'd do them for both blocks).
When you are mixing static if and if (or version etc.), make it very
clear the difference.
-Steve
More information about the Digitalmars-d
mailing list