更新时间:2023-02-18 23:10:19
如果您只想使用 decltype
,您只需要额外的一个&
:
decltype(m(& bar :: foo))
pre>Given that I was passing the undefined function:
void foo(char, short);
I learned how to obtain the type
tuple
of the arguments by callingdecltype(m(foo))
with this function:template <typename Ret, typename... Args> tuple<Args...> m(Ret(Args...));
I would now like to pass an undefined method:
struct bar { void foo(char, short); };
I had tried rewriting
m
like:template <typename Ret, typename C, typename... Args> tuple<Args...> m(Ret(C::*)(Args...));
But when I try to call this similarly with
decltype(m(bar::foo))
I get the error:invalid use of non-static member function
void bar::foo(char, short int)
How can I pass this method like I did for the function?
If you only want to use
decltype
on it, you simply need an extra&
:decltype(m(&bar::foo))