Question
I have a function f taking some argument a, how can I make sure that the variable a is not used inside of the body, in the best case via a compile error? E.g., the following should not compile
void f( int & a ) {
UNUSED( a ); // some magic rendering the variable a unusable
++a;
}
Story of the question:
In some of my functions, some variables are unused when compiled in release mode and are used in debug mode. Thus, to silence warnings I made myself an UNUSED( varname ) macro. But then, I realized that the proper name of the macro should be MAYBE_UNUSED( varname ).
Use case of UNUSED()
I have a set of implementations of a (hard to compute) function. The implementations shall all have the same signature, so they can easily be replaced with one another. But some implementations must not use certain input arguments. To make this explicit (for the reader and compiler) such UNUSED magic would be useful.