#include <iostream>
#include <tuple>
#include <typeinfo>
template <typename T>
struct function_traits;
struct void_type { using type = void; };
template <typename T_Ret, typename ...T_Args>
struct function_traits<T_Ret(T_Args...)> {
// Number of arguments.
enum { arity = sizeof...(T_Args) };
// Argument types.
template <size_t i>
struct args {
using type
= typename std::conditional<(i < sizeof...(T_Args)),
std::tuple_element<i, std::tuple<T_Args...>>,
void_type>::type::type;
};
};
int main() {
using Arg0 = function_traits<int(float)>::args<0>::type;
using Arg1 = function_traits<int(float)>::args<1>::type;
std::cout << typeid(Arg0).name() << std::endl;
std::cout << typeid(Arg1).name() << std::endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dHVwbGU+CiNpbmNsdWRlIDx0eXBlaW5mbz4KCnRlbXBsYXRlIDx0eXBlbmFtZSBUPgpzdHJ1Y3QgZnVuY3Rpb25fdHJhaXRzOwoKc3RydWN0IHZvaWRfdHlwZSB7IHVzaW5nIHR5cGUgPSB2b2lkOyB9OwoKdGVtcGxhdGUgPHR5cGVuYW1lIFRfUmV0LCB0eXBlbmFtZSAuLi5UX0FyZ3M+CnN0cnVjdCBmdW5jdGlvbl90cmFpdHM8VF9SZXQoVF9BcmdzLi4uKT4gewogICAgLy8gTnVtYmVyIG9mIGFyZ3VtZW50cy4KICAgIGVudW0geyBhcml0eSA9IHNpemVvZi4uLihUX0FyZ3MpIH07CgogICAgLy8gQXJndW1lbnQgdHlwZXMuCiAgICB0ZW1wbGF0ZSA8c2l6ZV90IGk+CiAgICBzdHJ1Y3QgYXJncyB7CiAgICAgICAgdXNpbmcgdHlwZQogICAgICAgICAgICA9IHR5cGVuYW1lIHN0ZDo6Y29uZGl0aW9uYWw8KGkgPCBzaXplb2YuLi4oVF9BcmdzKSksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGQ6OnR1cGxlX2VsZW1lbnQ8aSwgc3RkOjp0dXBsZTxUX0FyZ3MuLi4+PiwKICAgICAgICAgICAgICAgICA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