I wrote a metafunction to get the type of the first parameter of a member function, which, of course, receives one or more parameters. The code I wrote is as follows:
template <typename...> struct parameter; template < typename O, typename A, typename R, typename... Args> struct parameter <R (O::*)(A, Args...) > { using first_param = A; };
I use this meta function as follows:
using mem_fn = void(mem_type::*)(std::vector<int>); using f_pm = parameter<mem_fn>::first_param;
and it compiles and works. But when I have a class:
struct mem_type{ void update(std::vector<int>) { } };
and use my metaphor as follows:
using mem_fn = decltype(mem_type::update); using f_pm = parameter<mem_fn>::first_param;
the code does not compile, but visual studio 2013 gives: error C2027: using undefined type parameter<mem_fn> .
Does anyone know the cause of this error?
c ++ c ++ 11 templates template-meta-programming
Raul alonso
source share