How do I get a specific type from a variadic type pack?

Viewed 620

I wish to do something like this:

template<typename ...T> struct foo
{
  bar<0 /*to index through types in pack*/ ,T...>::type var1;
  bar<1 /*to index through types in pack*/ ,T...>::type var2;
  ...
}

But how would I define bar? No recursion technique comes to mind to do this.

I want a general technique so that I could typedef any particular type from a type pack, not just the two shown in the example.

4 Answers
Related