Date: Tue, 20 Dec 2022 02:00:34 -0500
As a semi-serious/semi-joking suggestion in existing C++ `delete
std::exchange(p,nullptr);`.
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.
On Tue, Dec 20, 2022 at 01:51 Frederick Virchanza Gotham via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> It's common that you'll see the following two lines in C++ code:
>
> delete p;
> p = nullptr;
>
> How about allowing it as follows?
>
> delete p = nulltpr;
>
> The 'delete' operator has higher precedence than assignment, so it
> won't be parsed as "delete (p = nullptr)" which would be a problem.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
std::exchange(p,nullptr);`.
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.
On Tue, Dec 20, 2022 at 01:51 Frederick Virchanza Gotham via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> It's common that you'll see the following two lines in C++ code:
>
> delete p;
> p = nullptr;
>
> How about allowing it as follows?
>
> delete p = nulltpr;
>
> The 'delete' operator has higher precedence than assignment, so it
> won't be parsed as "delete (p = nullptr)" which would be a problem.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2022-12-20 07:00:47