C++17 introduced the [[nodiscard]] attribute that triggers a compiler warning when the result of a function call is discarded.
At a minimum, this attribute should be used for functions that are expensive to run and query functions that might be confused with their action counterparts.
Compiler Explorer link: https://compiler-explorer.com/z/TMMojeKcd