Date: Tue, 20 Dec 2022 04:40:37 -0500
It would make more sense to use std::unique_ptr or std::shared_ptr from the
start.
On Tue, Dec 20, 2022 at 2:07 AM Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
> On Tue, Dec 20, 2022 at 7:00 AM connor horman via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
>
> > TBH, delete p = nullptr; reads too much like delete (p = nullptr);, even
> if it doesn't parse that way,
> > that I wouldn't ever want to use it, or attempt reading code that uses
> it.
>
>
> If you parse it like that, you know that it's pointless. You know that
> you wouldn't bother delete'ing a nullptr.
>
> The following two lines of code make no sense:
>
> p = nullptr;
> delete p;
>
> Therefore when you see "delete p = nullptr;", irrespective of whether
> you're familiar with operator
> precedence, you know that it must be setting the pointer to null after
> delete'ing it, because nothing
> else makes sense.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
start.
On Tue, Dec 20, 2022 at 2:07 AM Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
> On Tue, Dec 20, 2022 at 7:00 AM connor horman via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
>
> > TBH, delete p = nullptr; reads too much like delete (p = nullptr);, even
> if it doesn't parse that way,
> > that I wouldn't ever want to use it, or attempt reading code that uses
> it.
>
>
> If you parse it like that, you know that it's pointless. You know that
> you wouldn't bother delete'ing a nullptr.
>
> The following two lines of code make no sense:
>
> p = nullptr;
> delete p;
>
> Therefore when you see "delete p = nullptr;", irrespective of whether
> you're familiar with operator
> precedence, you know that it must be setting the pointer to null after
> delete'ing it, because nothing
> else makes sense.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2022-12-20 09:41:05