相关疑难解决方法(0)

带有函数类型参数的C++模板的语法

我习惯于在函数指针中看到这样的语法

int (*pointer_name) (float, char *);
void call_function (void (*)(int), int);
Run Code Online (Sandbox Code Playgroud)

在一些C++ 03函数库中,我看到以这种方式使用的类型:

abc::function<void(*)(int,float)> f;
Run Code Online (Sandbox Code Playgroud)

在C++ 11中,std::function我看到了这种方式给出的类型

std::function<void(int,float)> f;
Run Code Online (Sandbox Code Playgroud)

有一个失踪(*).为什么?

在C++ 03 function<T>已经T是相同的类型到相应的函数指针.很容易想象实现.

std::function在C++ 11中,核心语言增强功能支持它.是否已扩展模板参数类型以适应可调用性?

c++ templates c++11 std-function

15
推荐指数
3
解决办法
3360
查看次数

标签 统计

c++ ×1

c++11 ×1

std-function ×1

templates ×1