C++ nodiscard attribute
C++17
and
C23
added the [[nodiscard]]
attribute to indicate that the result of a function call should not be ignored.
However, a C++26 proposal to remove [[nodiscard]]
from the language standard is under consideration.
Example: annotate function declaration in the header file with [[nodiscard]]
attribute.
[[nodiscard]] int one();
int one() { return 1; }