Suppresses warnings on unused entities.
[edit] Syntax [edit] ExplanationThis attribute can appear in the declaration of the following entities:
For entities declared [[maybe_unused]], if the entities or their structured bindings are unused, the warning on unused entities issued by the compiler is suppressed.
For labels declared [[maybe_unused]], if they are unused, the warning on unused labels issued by the compiler is suppressed.
(since C++26) [edit] Example#include <cassert> [[maybe_unused]] void f([[maybe_unused]] bool thing1, [[maybe_unused]] bool thing2) { [[maybe_unused]] lbl: // the label âlblâ is not used, no warning [[maybe_unused]] bool b = not false and not true; assert(b); // in release mode, assert is compiled out, and âbâ is unused // no warning because it is declared [[maybe_unused]] } // parameters âthing1â and âthing2â are not used, no warning int main() {}[edit] Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR Applied to Behavior as published Correct behavior CWG 2360 C++17 could not apply [[maybe_unused]] to structured bindings allowed [edit] ReferencesRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4