C++ Logo

std-proposals

Advanced search

Re: Initialisers in ternary operators

From: Richard Hodges <hodges.r_at_[hidden]>
Date: Fri, 11 Sep 2020 08:56:43 +0200
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);
    });


On Fri, 11 Sep 2020 at 09:19, Dmitry Dmitry via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Just write and use a find wrapper like these:
>>
>
> It was just an example.
> If we start considering solving it via wrappers/helpers, then I would just
> create something like findOr(key, value) function.
>
> But, anyway, it seems that the idea is not worth it...
> Thanks for the feedback.
>
> --
> Dmitry
> *Sent from gmail*
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>


-- 
Richard Hodges
hodges.r_at_[hidden]
office: +442032898513
home: +376841522
mobile: +376380212

Received on 2020-09-11 04:00:26