我想知道是否可以将模板函数(或其他)作为参数传递给第二个函数(不是模板).询问谷歌这个似乎只提供相反的信息(作为模板参数传递的函数)
我能找到的唯一相关页面是http://www.beta.microsoft.com/VisualStudio/feedbackdetail/view/947754/compiler-error-on-passing-template-function-as-an-argument-to-a-功能与省略号 (不是很有帮助)
我期待的是:
template<class N>void print(A input){cout << input;}
void execute(int input, template<class N>void func(N)){func(input)}
Run Code Online (Sandbox Code Playgroud)
然后打电话
execute(1,print);
Run Code Online (Sandbox Code Playgroud)
那么,这可以完成还是必须为execute()定义另一个模板?