C++ Logo

std-proposals

Advanced search

Re: [std-proposals] condexpr: new syntax for preprocessor conditional inclusion

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Tue, 13 Dec 2022 11:05:24 -0500
On Tue, Dec 13, 2022 at 1:13 AM Michael Levine via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> I propose that we introduce the following new preprocessor conditional inclusion syntax:
>
> condexpr if (expression or identifier, expression or identifier...) {
> ....the conditional logic....
> }
>
> New keyword to reserve: condexpr
>
> Some advantages:
> - The syntax looks more like standard C++ code and less like preprocessor directives

But you still want it to *behave* like a preprocessor directive. So...
why should it *not* look like one? Sounds like you want some form of
false advertising.

> - Rather than writing the preprocessor conditional inclusion syntax like #ifdef and #endif at the beginning of each line, which breaks the flow of code if the code is already nested, this syntax can be written directly into the regular C++ code.

But it *isn't* "regular C++ code". It's preprocessor code. Also, C++
doesn't care about whitespace; you can indent preprocessor directives
if you like.

Received on 2022-12-13 16:07:47