鉴于我正在传递 undefined 函数:
void foo(char, short);
我learned how通过使用此函数调用 decltype(m(foo))
来获取参数的类型 tuple
:
template <typename Ret, typename... Args>
tuple<Args...> m(Ret(Args...));
我现在想传递一个未定义方法:
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))
类似,我得到错误:
invalid use of non-static member function
void bar::foo(char, short int)
如何像传递函数一样传递此方法?
最佳答案
如果你只想在上面使用decltype
,你只需要一个额外的&
:
decltype(m(&bar::foo))
关于c++ - 如何像传递未定义函数一样传递未定义方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38482805/