Problem
Given any function (or callable) type
Function
, how can I get its all arguments types as a tuple type ?
For example, I need a trait function_traits<Function>::arguments
, where:
int f();
typename function_traits<decltype(f)>::arguments // => gives me std::tuple<>
void g(int);
typename function_traits<decltype(g)>::arguments // => gives me std::tuple<int>
void h(int, int);
typename function_traits<decltype(h)>::arguments // => gives me std::tuple<int, int>
My thought
First
I need to get the size of arguments, fortunately boost already has implemented function_traits<F>::arity
Then
Generate an std::integer_sequence
from 1 to artify, map it to arguments type, but here comes the problem, to map integer_sequence
, I need something like this:
function_traits<F>::arg_type<N> // -> N-th arg_type
but boost only provides this:
function_traits<F>::argN_type
Question
How can I implement function_traits<F>::arg_type<N>
? I can use c++ standard up to c++17