I want to make a template where I can input an index and it will give me the type at that index. I know I can do this with decltype(std::get but
You can use a class template and partial specializations to do what you want. (Note that std::tuple_element does almost the same like the other answer says):
#include
#include
template
struct get;
template
struct get>
{
using type = typename get>::type;
};
template
struct get<0, std::tuple>
{
using type = T;
};
int main()
{
using var = std::tuple;
using type = get<2, var>::type;
static_assert(std::is_same::value, ""); // works
}