Summary
Jason compares three approaches for explicitly ignoring return values from [[nodiscard]] functions: std::ignore (C++11), [[maybe_unused]] attribute (C++17), and the underscore placeholder (C++26). While std::ignore can have compile-time and debug-time overhead, and [[maybe_unused]] requires meaningful variable names and can't selectively ignore parts of structured bindings, the C++26 underscore feature excels at allowing partial ignoring of decomposed values. The underscore approach permits multiple unreachable variables with the same name and is particularly useful for structured bindings where only some values are needed.
Related C++ Standard Sections
This episode covers topics found in these sections of the C++ standard:
-
[variant]100% match -
[diff.cpp23.expr]43% match -
[diff.cpp23]40% match