Get the Nth type of variadic template templates?
You can use std::tuple
:
#include<tuple>
template<typename... Args>
class MyClass
{
typename std::tuple_element<0, std::tuple<Args...> >::type mA;
};
If you want something without using std::tuple
this works
template<std::size_t N, typename T, typename... types>
struct get_Nth_type
{
using type = typename get_Nth_type<N - 1, types...>::type;
};
template<typename T, typename... types>
struct get_Nth_type<0, T, types...>
{
using type = T;
};
Than
template<std::size_t N, typename... Args>
using get = typename get_Nth_type<N, Args...>::type;
template<typename... Args>
class MyClass
{
get<0, Args...> mA;
};