Daily bit(e) of C++ | [[nodiscard]]
Daily bit(e) of C++ ♻️113, Marking functions whose result shall not be ignored using the [[nodiscard]] attribute.
C++17 introduced the [[nodiscard]] attribute that triggers a compiler warning when the result of an annotated function call is discarded.
At a minimum, this attribute should be used for functions whose primary purpose is to compute the result and for query functions that might be confused with their action counterpart.
Since C++20, the attribute can be customized with a string literal that will be part of the produced warning.