メタプログラミングをするときにたまに関数の引数の型がを知りたいときがあるのでメモ。 std::tupleとstd::tuple_elementを使って実装します。 #include <type_traits> #include <tuple> template <std::size_t N, class...Args> struct arg_type_impl { using type = typename std::tuple_element<N, std::tuple<Args...>>::type; }; // 可変個引数テンプレート template <std::size_t N, class... Args> struct arg_type { using type = typename arg_type_impl<N, Args...>::type; }; // 関数 temp