templates - C++ deduce member function parameters -


i'm looking extend functionality described here member functions, syntax in case?

also, (*) in template definition, de-referencing function pointer compiler can deduce template arguments?

would appreciate input!

thanks

template <class f> struct argtype;  template <class r, class t>  struct argtype<r(*)(t)> {   typedef t type; };   void f(int) {}  #include <type_traits> #include <iostream>  int main() {    // prove   std::cout << std::is_same< argtype<decltype(&f)>::type, int >::value << '\n';    // use   argtype<decltype(&f)>::type a; } 

pointer-to-members ret (cls::*)(args...) [cv-qualifiers] [ref-qualifiers]. can extend class deduce first type thusly:

template <class f> struct argtype;  template <typename ret, typename cls, typename t, typename... args> struct argtype<ret (cls::*)(t, args...)> {     using type = t: }; 

note can make more generic write metafunction gives nth argument:

template <typename ret, typename cls, typename... args> struct argtype<ret (cls::*)(args...)> {      template <size_t n>     struct get_arg {         using type = typename std::tuple_element<n,                         std::tuple<args...>>::type;     }; }; 

so argtype<f>::arg<0>::type type seek.