C++ Logo

std-proposals

Advanced search

Re: [std-proposals] return if

From: Alejandro Colomar <une+cxx_std-proposals_at_[hidden]>
Date: Wed, 14 Jan 2026 00:58:42 +0100
Hi Frederick,

On Tue, Jan 13, 2026 at 11:50:02PM +0000, Frederick Virchanza Gotham via Std-Proposals wrote:
> On Tue, Jan 13, 2026 at 11:28 PM Thiago Macieira wrote:
> >>
> > > return ! if SomeFunction();
> > >
> > > which would become:
> > >
> > > if ( decltype(auto) x = SomeFunction() ) return !x;
> >
> > What's the motivation for this syntactic sugar? It's saving four words
> > (decltype, auto, and the variable name twice).
>
>
> No actually it's a bit longer than that:
>
> if ( decltype(auto) x = SomeFunction() ) return
> !static_cast<decltype(x)>(x);
>
> decltype, auto, static_cast, decltype, and the variable name three times

And do you invert vectors like that so often? Don't you think it's
better to be explicit when you do weird stuff?


Have a lovely night!
Alex

-- 
<https://www.alejandro-colomar.es>

Received on 2026-01-13 23:58:48