C++ Logo

std-proposals

Advanced search

Re: Function proposal: generic value_or

From: Francesco Pretto <ceztko_at_[hidden]>
Date: Wed, 18 Aug 2021 10:25:42 +0200
On Wed, 7 Jul 2021 at 11:18, Ville Voutilainen via Std-Proposals
<std-proposals_at_[hidden]> wrote:
> It's not at all obvious to me why something like this should have a
> dedicated core language syntax
>

One could argue the same for the comma operator (expression)[1], which
I personally never found practical uses or I was always able to
replace it with something more readable. Instead I used null
coalescing operator[2] profitably several times in C#. Its existence
in a language can also be justified by the concomitant availability of
the safe navigation operator, or null-conditional operator, which has
of course more use cases. Off-topic: has the safe navigation operator
being proposed as well?

Cheers,
Francesco

[1] https://en.wikipedia.org/wiki/Comma_operator
[2] https://en.wikipedia.org/wiki/Null_coalescing_operator
[3] https://en.wikipedia.org/wiki/Safe_navigation_operator

Received on 2021-08-18 03:25:55