【发布时间】:2016-03-06 06:06:37
【问题描述】:
考虑以下代码:
template <class>
struct test: std::integral_constant<int, 0> {};
template<class R, class C, class... Args>
struct test<R(C::*)(Args...)>: std::integral_constant<int, 1> {};
template<class R, class C, class... Args>
struct test<R(*C::*)(Args...)>: std::integral_constant<int, 2> {};
template<class R, class C, class... Args>
struct test<R(**C::*)(Args...)>: std::integral_constant<int, 3> {};
template<class R, class C, class... Args>
struct test<R(C::**)(Args...)>: std::integral_constant<int, 4> {};
template<class R, class C, class... Args>
struct test<R(C::***)(Args...)>: std::integral_constant<int, 5> {};
我完全不知道(*C::*)、(**C::*)、(C::**) 和(C::***) 是什么意思。我想要一个test<decltype(f)> 的示例,其value 将等于2、3、4 和5。另外,在这种情况下,调用成员函数的f 的语法如何?
【问题讨论】:
标签: c++ c++11 member-function-pointers member-functions