I have seen example code like this before
class C
{
C();
~C();
foo(T1, T2);
}
C::foo(T1, T2)
{
//not using T1/T2
}
versus conventional code like this
class D
{
D();
~D();
bar(T1 t1, T2 t2);
}
D::bar(T1 t1, T2 t2)
{
//using t1 and t2
}
And I am wondering what is the purpose of not defining your type variables for usability? Do most people do this just to hint that those parameters of the api are not currently in use, but to ensure backward compatibility in the future?
Is it possibly for RTTI, or referencing static variables (although the various samples I’ve seen were not using it for this purpose, they werent even templated functions, the variables were simply unused). I’ve tried searching for this feature but I am not even sure what it is called or what to search.
Basically, what are the reasons/benefits/downsides for using this approach?
This is commonly done to suppress compiler warnings about unused variables. When you do not create a variable name, the compiler will not warn you that the variable is not being used in the function.
Like you stated, its usually that parameters are not being used for the particular implementation: