Suppose I have a template function that takes an integer as the template argument as follows:
template <int i> void f(int x) {...}
Now I want to write another function that takes the function f
as an argument. However I do not know how to achieve this. For example, consider the following wrong code (that can not be compiled):
template <template <int> typename T> void g(T fun, int i, int x) {
if (i == 0) fun<0>(x);
else if (i == 1) fun<1>(x);
//...
}
I have searched Google but It seems that all related questions are to pass a standard function as a template argument which is not the case here. Hope anyone can help me. Thank you very much!