C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Allow chaining of -> for normal pointers

From: Marcin Jaczewski <marcinjaczewski86_at_[hidden]>
Date: Sun, 8 Jan 2023 12:27:16 +0100
niedz., 8 sty 2023 o 05:05 Thiago Macieira via Std-Proposals
<std-proposals_at_[hidden]> napisaƂ(a):
>
> On Saturday, 7 January 2023 15:52:31 -03 Frederick Virchanza Gotham via Std-
> Proposals wrote:
> > Was there every any discussion about allowing "->" chaining for pointers?
>
> Not that I've ever seen.
>
> Please give a reason why this should have been considered. And please give a
> reason why this should be considered *now* when the current paradigm is to
> avoid raw pointers as much as possible and instead use smart pointer wrappers
> of one sort or another.
>
Another thing is asking for bugs, like:
```
if (ptr) ptr->foo(); //boom! `ptr` point to null pointer
```
Now is clear that you need multiple tests as you have multiple `*`
```
if (ptr && *ptr && **ptr) (**ptr)->foo();
```

> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel DCAI Cloud Engineering
>
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2023-01-08 11:27:27