How to pass an Undefined method As an Undefined function

Given that I passed the undefined function:

void foo(char, short); 

I learned how to get the type of tuple arguments by calling decltype(m(foo)) with this function:

 template <typename Ret, typename... Args> tuple<Args...> m(Ret(Args...)); 

Now I would like to pass the undefined method:

 struct bar { void foo(char, short); }; 

I tried to rewrite m as:

 template <typename Ret, typename C, typename... Args> tuple<Args...> m(Ret(C::*)(Args...)); 

But when I try to call it in the same way as decltype(m(bar::foo)) I get an error:

invalid use of non-static member function void bar::foo(char, short int)

How to pass this method, as I did for the function?

+1
c ++ function methods expression member-function-pointers
source share
1 answer

If you want to use only decltype , you just need an extra & :

 decltype(m(&bar::foo)) 
+2
source share

All Articles