小编wil*_*els的帖子

从成员函数指针类型中删除类指针

我在cppreference的std :: is_function的示例中看到了此代码片段,但我不知道它是如何工作的。有人可以向我解释为什么U像在PM_traits中那样被推导吗?

struct A {
  int fun() const&;
};

template<typename>
struct PM_traits {}; 

template<class T, class U>
struct PM_traits<U T::*> {
  using member_type = U;
};

int main() {
  using T = PM_traits<decltype(&A::fun)>::member_type; // T is int() const&
}
Run Code Online (Sandbox Code Playgroud)

c++ templates c++11

7
推荐指数
1
解决办法
200
查看次数

标签 统计

c++ ×1

c++11 ×1

templates ×1