C++ Logo

std-proposals

Advanced search

Re: Ptr proposal: looking for feedback

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Fri, 17 Jul 2020 18:04:34 +0300
On Fri, 17 Jul 2020 at 17:55, Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]> wrote:

>> ..but if the parameter of betterfunc is supposed to be nullable, none
>> of that nonsense works.
> If it's supposed to be nullable, pass a pointer. Since you don't want to mess with ownership, pass a raw pointer.

A raw pointer doesn't mean that ownership is not transferred (it
doesn't clearly mean the opposite either).

> void betterfunc(Foo *pf);
> ... betterfunc(&local); ... // no ownership
> ... betterfunc(std::make_unique<Foo>(42).get()); ... // construct an owning unique_ptr, and then deallocate it afterward
> ... betterfunc(nullptr); ... // pass null
>
> Calling it "nonsense" is a bit much. Trust me; I do this stuff for a living, and also teach it. :)

Don't push your luck. Suggesting that references are a replacement for
any sort of pointers will get such
characterizations from me regardless of what you claim to do and
teach. People who suggest that I should
trust them need to earn it, which takes a bit of work; suggesting to
me that I should trust them since they do it for a living
is hilarious, considering what I do and have done for a living for
quite some time.

Received on 2020-07-17 10:08:17