相关疑难解决方法(0)

有没有理由我们无法在未评估的上下文中命名非静态成员函数?

阅读[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()即使在检查静态断言之前,它也是不正确的.

是否有一些我不知道的歧义?

c++ language-lawyer

9
推荐指数
1
解决办法
349
查看次数

标签 统计

c++ ×1

language-lawyer ×1