C++ Logo

std-proposals

Advanced search

Re: Initialisers in ternary operators

From: Dmitry Dmitry <dimanne_at_[hidden]>
Date: Thu, 10 Sep 2020 22:17:26 +0100
>
> You can probably already have a similar outcome with:
>
> return [&] { auto It = Cont.find(42); return It == Cont.end() ? 0 :
> It->second; }();
>
> which is not that much longer.
>

Yeah... Right.

But what about consistency (between regular if()'s and ternary operators)?
It just reminds me how initially, auto parameters were invented in lambdas
and then they were "ported" to regular function.
Ditto here, initially init-statements were introduced in regular if()'s,
but kind-of-forgotten in ternary operators?

-- 
Dmitry
*Sent from gmail*

Received on 2020-09-10 16:21:23