C++ Logo

std-proposals

Advanced search

Re: [std-proposals] if !(condition)

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Sat, 20 Apr 2024 13:55:15 -0400
On Sat, Apr 20, 2024 at 12:09 PM Yexuan Xiao via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> I've wrote a proposal that suggests allowing the omission of the outermost parentheses to simplify the conditions in if statements:
> https://storage.nykz.org/proposals/if-not/
>
> Please share your comments.

I really don't like that you can put an initializer statement inside
of the `!` parentheses. That can put a lot of distance between the
negation and the expression being negated. If `if!` is going to be a
thing, it shouldn't be able to be used with initializers. If you add
an initializer, just put the negation with the expression where it
belongs.

Similarly, I think `constexpr` should come before the `!`, not after.

Received on 2024-04-20 17:55:27