C++ Logo

std-proposals

Advanced search

Re: Initialisers in ternary operators

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Fri, 11 Sep 2020 12:11:24 +0300
On Fri, 11 Sep 2020 at 11:57, Richard Hodges via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> GCC already has expression statements as an extension.
>
> I don't think it would hurt to standardise this into the language.
>
> https://godbolt.org/z/sb63dz
>
> e.g.:
> return ({
> auto i = m.find(x) ;
> i == m.end() ? nullptr : std::addressof(i->second);
> });

Yeah, well,

return [&] {
  auto i = m.find(x) ;
  return i == m.end() ? nullptr : std::addressof(i->second);
}();

Received on 2020-09-11 04:15:09