@Magnus I think the same point, i.e. just saving a few keystrokes, could be made about ranged-for.

I like the underlying idea but like the others have said, the implicit * in there as opposed to a more general concept sits a little uneasy. It is programmable behaviour though which is a big plus. I'd like to see more examples!



On Sun, 27 Oct 2019, 7:24 am Magnus Fromreide via Std-Proposals, <std-proposals@lists.isocpp.org> wrote:
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@lists.isocpp.org
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals