C++ Logo

std-proposals

Advanced search

Re: [std-proposals] The null-aware arrow operator: ?->

From: Richard Hodges <hodges.r_at_[hidden]>
Date: Thu, 20 Oct 2022 13:00:55 +0200
On Thu, 20 Oct 2022 at 12:25, Peter Olsson via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> If you don't use a colon (:) does that mean the type of the ?-> expression
> is always void?
>
> You can't write the following, can you?
> std::cout << ptr?->get_value();
>

These are equivalent:

ptr ? std::cout << ptr->get_value(), void() : void();
ptr ? std::cout << ptr->get_value() : std::cout;
if (ptr) std::cout << ptr->get_value();

The "optional operator" is unnecessary syntactic sugar found in a couple of
populist languages.


> >The three-way comparison operator <=> is 3 chars long; ?-> now seems
> reasonable IMHO.
>
> There are also <<= and >>= so I don't think the length should be
> controversial.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2022-10-20 11:01:09