I wanted a generic way to process functions and eventually call them so I wrote the code below the problem is that the code is compiling but when I tested it I get errors of kind
wrong number of template arguments (1, should be 0) auto al= action::apply<5>::value;
so I know that I'm doing something wrong but I couldn't find out what it is.
template<typename T, typename enabled=void, typename ...P>
struct action{
template<P... args>
struct apply{ };
};
template<typename FN,typename ...P>
struct action<FN, typename std::enable_if< std::is_function<FN>::value >::type ,P...>{
template<P... args>
struct apply{
static const decltype( std::result_of<FN(P...)>::type ) value = FN( std::forward<P>(args)...);
};
};
int test(int x)
{
return x;
}
int main()
{
auto al= action<decltype(test), int>::apply<5>::value;
std::cout << "result :" << al <<std::endl;
return 0;
}
Aucun commentaire:
Enregistrer un commentaire