C++ Logo

std-proposals

Advanced search

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

From: Phil Endecott <std_proposals_list_at_[hidden]>
Date: Thu, 29 Jun 2023 16:01:11 +0100
Harald Achitz 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]]

It seems to me that we are using [[nodiscard]] for two things. Sometimes
the caller is expected to actually inspect the function return value;
examples are functions that return success/error indications that should
be checked, and functions where the user might be confused about whether
it returns a result or modifies an in-out parameter.

In other cases, the returned type is something with a non-trivial destructor
and the requirement is only that it continues to exist to the end of
the scope,
rather than being discarded immediately; the obvious example is locks. This
is less strict.

Perhaps we really need two different attributes for the two cases?


Regards, Phil.

Received on 2023-06-29 15:01:13