In C++ there’s an attribute called nodiscard which solves this problem assuming the API you’re consuming is written well. When you apply this attribute to a function, the compiler emits a warning when that function’s return value isn’t used by the developer [1].
Lots of other languages take the same approach. Rust’s must_use attribute is basically the same as nodiscard.
Lots of other languages take the same approach. Rust’s must_use attribute is basically the same as nodiscard.
It’s a nice way of solving the problem imo.
[1] https://en.cppreference.com/w/cpp/language/attributes/nodisc...