11

今天我查看了Stroustrup 的 C++11 FAQ(2013 年 4 月 7 日修改),并在类型别名部分的末尾看到了这一点:

typedef void (*PFD)(double);    // C style
using PF = void (*)(double);    // using plus C-style type
using P = [](double)->void;     // using plus suffix return type

其中 lambda 引入器用于启动使用后缀样式返回类型的通用函数类型表达式。这是官方的,还是放弃的测试版/愿望清单功能?如果它是官方的,它将如何用于非静态成员函数?

4

1 回答 1

11
using P = [](double)->void;

is not official. Bjarne is known to be a bit careless in his FAQs.

What does work, however, are the following:

using P1 = auto(double) -> void;
using P2 = auto(*)(double) -> void;

Where P1 is a function type, and P2 is a function-pointer type. Maybe that was his intention.

于 2013-04-30T06:30:19.557 回答