阅读[expr.prim.id]时,会看到这一点
只能使用表示非静态数据成员或类的非静态成员函数的id表达式:
- 如果该id-expression表示非静态数据成员,则它出现在未评估的操作数中.
上面的子弹仅适用于数据成员这一事实对我来说并不清楚.直觉上我希望以下内容形成良好:
#include <type_traits>
using func = int();
class bar {
func foo; // This is valid, and not the subject of the question
};
static_assert(std::is_same<decltype(bar::foo), func>::value, "No Symmetry!");
Run Code Online (Sandbox Code Playgroud)
但decltype()即使在检查静态断言之前,它也是不正确的.
是否有一些我不知道的歧义?