考虑以下代码:
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
的语法调用成员函数?
s
有一个函数成员int f(int x) {return x;}
,并且testN
引用它,那么在变量上执行testN
的语法是什么? - Vincent