【发布时间】:2011-11-06 21:31:46
【问题描述】:
我习惯于看到这样的函数指针语法
int (*pointer_name) (float, char *);
void call_function (void (*)(int), int);
在一些 C++03 函数库中,我看到使用这种方式的类型:
abc::function<void(*)(int,float)> f;
在 C++11 的 std::function 中,我看到了以这种方式给出的类型
std::function<void(int,float)> f;
缺少(*)。为什么?
C++03 function<T> 的 T 与对应的函数指针的类型相同。很容易想象它的实现。
核心语言增强支持 C++11 中的std::function。是否扩展了模板参数类型以适应可调用性?
【问题讨论】:
标签: c++ templates c++11 std-function