【发布时间】:2018-08-21 02:53:38
【问题描述】:
如何使用 new1using 关键字声明函数类型?
我知道如何使用它来声明函数指针类型。比如下面的typedef:
typedef int (*int_to_int)(int);
似乎等同于以下 using 声明:
using int_to_int = int (*)(int);
我如何对以下非指针 typedef 做同样的事情:
typedef int (int_to_intf)(int);
我的“删除 typedef 名称并将其放在 using 之后”算法不起作用:
using int_to_intf_u = int ()(int); // nope, doesn't compile
1 至少对于像我这样仍然将“新”定义为“在 C++11 中引入”的可怜人来说。
【问题讨论】:
-
回想一下你是如何使用 std::function 的。
-
@liliscent - 哈哈,没错。我不知何故从未建立过联系(请参阅我在看到此之前写的答案中的 cmets,因为编辑时间戳不能证明这一点,您必须相信我的话)。
标签: c++ c++11 using-declaration