Open
Description
I noticed today that [[nodiscard]]
isn't present in this set of guidelines (apart from not ignoring results of functions declared nodiscard and not using void casts to ignore). I think there are some clear cases where guidance would help people:
- When a stateless function has a non-void return value and no output parameters.
- With functions that return error codes, especially the new
std::expected
and almost alwaysstd::optional
's.
Some broad guidance may also be useful, such as:
- "When it doesn't make sense for the caller of a function to discard the result, declare it
[[nodiscard]]
"
Metadata
Metadata
Assignees
Labels
No labels