Boost logo

Boost :

From: Gavin Lambert (boost_at_[hidden])
Date: 2022-04-18 23:40:28


On 17/04/2022 03:59, Glen Fernandes wrote:
> Doesn't always work. For example: https://godbolt.org/z/3zn11ErKG

That's not really a common usage pattern, though, unless there are some
conditional compilation constructs (#if or assert) involved; you just
wouldn't assign it to a variable in the first place.

Typically `(void) x` is only used for parameters, and `(void) f()` for
method calls (although most compilers will not complain by default about
discarded return values, though that can usually be enabled).

> For those rare users that can afford to target C++17 or higher, they
> have [[maybe_unused]]

That attribute name irks me. [[may_be_unused]] would have been better,
or just [[unused]] (to save typing).

"May be unused" denotes permission, while "maybe unused" denotes
uncertainty. And you shouldn't be uncertain about your code.

Also compare with [[nodiscard]] (and as always, C++ having the opposite
default of the correct one, due to backwards compatibility).


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk