鉴于我正在传递 undefined 函数:
void foo(char, short);
我learned how通过使用此函数调用tuple
来获取参数的类型decltype(m(foo))
:
template <typename Ret, typename... Args>
tuple<Args...> m(Ret(Args...));
我现在要传递 undefined 方法:
struct bar { void foo(char, short); };
我曾尝试重写m
,如:
template <typename Ret, typename C, typename... Args>
tuple<Args...> m(Ret(C::*)(Args...));
但是当I try to call this与decltype(m(bar::foo))
类似时,我收到错误:
无效使用非静态成员函数
void bar::foo(char, short int)
如何像我对函数一样传递此方法?
答案 0 :(得分:2)
如果您只想在其上使用decltype
,则只需要额外&
:
decltype(m(&bar::foo))