C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Dummy names for dummy objects

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Thu, 29 Jun 2023 09:57:07 -0400
On Thu, Jun 29, 2023 at 3:23 AM Harald Achitz via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> Is the discussion about `auto _ = f()` actually done?
>
> Just asking since I still think it's a bad idea to allow that as a short form to ignore return values for functions marked as [[nodiscard]]

Um, why not?

The point of `nodiscard` is to catch *accidental* misuse of a return
value. You don't do `auto _ = f();` by accident. If a user chooses to
deliberately discard a return value, they should be able to do so, but
the fact that they do so should not be *invisible*. And this `auto _
=` is hardly invisible.

Received on 2023-06-29 13:57:18