【发布时间】:2015-08-31 12:58:12
【问题描述】:
我想知道是否可以将模板函数(或其他)作为参数传递给第二个函数(不是模板)。 向 Google 询问这件事似乎只会提供相反的信息 (Function passed as template argument)
我能找到的唯一相关页面是http://www.beta.microsoft.com/VisualStudio/feedbackdetail/view/947754/compiler-error-on-passing-template-function-as-an-argument-to-a-function-with-ellipsis (不是很有帮助)
我期待这样的事情:
template<class N>void print(A input){cout << input;}
void execute(int input, template<class N>void func(N)){func(input)}
然后再调用
execute(1,print);
那么,可以这样做还是必须为 execute() 定义另一个模板?
【问题讨论】: