C++ attribute: maybe_unused (since C++17)

Suppresses warnings on unused entities.

# Example

#include <cassert>
 
[[maybe_unused]] void f([[maybe_unused]] bool thing1,
                        [[maybe_unused]] bool thing2)
{
    [[maybe_unused]] lb: // the label “lb” is not used, no warning
    [[maybe_unused]] bool b = thing1 && thing2;
    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() {}

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
CWG 2360C++17could not apply [[maybe_unused]] to structured bindingsallowed

# See also