C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] Initial Idea of Indirect If Statement
From: Magnus Fromreide (magfr_at_[hidden])
Date: 2019-10-27 02:23:59


On Sun, Oct 27, 2019 at 02:14:51AM +1000, Andrew Tomazos via Std-Proposals wrote:
> We propose a new variant of the if statement that fuses a condition
> declaration with an indirection in the true branch. We call it an
> 'indirect if statement'.
>
> An indirect if statement of the form:
>
> if (DECL : EXPR) X else Y;
>
> is equivalent to:
>
> {
> auto&& __c = EXPR;
> if (__c) {
> DECL = *__c;
> X;
> } else {
> Y; // noteworthy: DECL is not in scope here
> }
> }

Is there any use case for this beyond saving a few keystrokes?

What does this enable that you couldn't do before?

Why is this particular construct important enough to warrant language support?

> So for example:
>
> int* get();
> /*...*/
> }
>
> The motivation should be self-evident enough from the examples for this
> first note.

I suppose that the fact that I have to ask proves that the motivation ain't
self-evident from the examples so please spell it out.

/MF

> Initial thoughts appreciated.
> -Andrew.

> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals


STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups