Das ist, was ich bisher habe:
Code: Select all
template
T Mean(Args ... args)
{
int numArgs = sizeof...(args);
if (numArgs == 0)
return T(); // If there are no arguments, just return the default value of that type
T total;
for (auto value : args...)
{
total += value;
}
return total / numArgs; // Simple arithmetic average (sum divided by total)
}
Code: Select all
error C3520: 'args' : parameter pack must be expanded in this context (test.cpp)
Mobile version