template struct function_traits<std::function<R(Args…)>>

#include <function_traits.h>

template <typename R, typename ... Args>
struct function_traits<std::function<R(Args...)>> {
    // typedefs

    typedef R result_t;
    typedef typename std::tuple_element<i, std::tuple<Args...>>::type arg_t;

    // fields

    static const size_t nargs = sizeof...(Args);
};