How can I explicitly instantiate a variadic function while calling it ?
The following code doesn't work and the compiler says that it couldn't convert the first parameter to a string &&
.
#include <iostream>
using namespace std;
template<typename ... Args>
void variadic( Args &&... args );
int main()
{
string str;
variadic<string &&, string &&>( str, ref( str ) );
}
template<typename ... Args>
void variadic( Args &&... args )
{
((cout << (void*)&args << endl), ...);
}
I have some code where the function object itself is a templated parameter which is invoked with some variadic parameters so that it has to be specialized before. Of course I could use a lambda as this parameter but maybe there's a simpler way.