The following thing is doable in C++:
#include <iostream>
using namespace std;
template <typename T>
class FooClass
{
public:
static void bar(T t, int i)
{
cout << t + i;
}
};
template<template<typename> typename target, typename ...Args>
void intermediateForClass(Args ...args)
{
target<int>::bar(1, args...);
}
int main(int, char**)
{
intermediateForClass<FooClass>(2);
return 0;
}
but actually in this situation, where I only have a class with a static method, I only need a function. But I couldnt manage to do the same with functions. I thought this code would work, but it does not:
#include <iostream>
using namespace std;
template<typename T>
void foo(T t, int i)
{
cout << t + i;
}
template<template<typename> typename target, typename ...Args>
void intermediateForFunctions(Args ... args)
{
target<int>(1, args...);
}
int main(int, char**)
{
intermediateForFunctions<foo>(2);
return 0;
}
It seems that actually there is a valid type for a class template, but not for a function template. Or am I doing something wrong? Is there anyway to get the 2nd version to work? If not, why so?