Windows 10, Visual Studio 2019, C++17:
Compile error: cannot convert argument 2 from 'int (__cdecl *)(int)' to '...'
////////////////////////////////////////////////////////////////////
// This is the templated function that becomes a variadic argument
//
template <typename siz>
int func(siz size)
{
// ...
// ...
return 0;
}
///////////////////////////////////////////////////////////
// This is the function that uses variadic arguments
//
int usefunc(int option, ...)
{
// ...
// ...
return 0;
}
int main()
{
int result;
result = usefunc(0, func); // ** int usefunc(int,...)': cannot convert argument 2 from 'int (__cdecl *)(int)' to '...' **
// Context does not allow for disambiguation of overloaded function
return result;
}
Without the template (int func(int size) ) the code compiles ok. How do I modify this to make the compiler understand the variadic argument?