Given a C++11 function:
X f(A, B, C);
Is there anyway from within this function:
template<typename T>
void g(T t)
{
...
}
Called as follows:
g(f);
to determine:
- the number of parameters of f
- the type of parameter i of f
- the return type of f
…
template<typename F>
void g(F f)
{
constexpr size_t n = num_params<F>::n; // 3
return_type<F>::type x; // X
tuple<param_types<F>::type...> a; // tuple<A, B, C>
}
?
Sure:
Usage: