If the parameter is definitely unused, [[maybe_unused]]
is not particularly useful, unnamed parameters and comments work just fine for that.
[[maybe_unused]]
is mostly useful for things that are potentially unused, like in
void fun(int i, int j) {
assert(i < j);
// j not used here anymore
}
This can't be handled with unnamed parameters, but if NDEBUG
is defined, will produce a warning because j
is unused.
Similar situations can occur when a parameter is only used for (potentially disabled) logging.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…