0

I'm new to c++11 and trying to make a function that runs objects

template<size_t I, typename... T>
void fun() {
    // use T here, may be something like
    // std::tuple_element<I, std::tuple<T...>>::type i;
    // i.run();
}

I don't know how to use the type in parameter pack, what's the correct grammar for this?

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
Wiki Wang
  • 668
  • 6
  • 23
  • What's the problem with your code? – Nicol Bolas Jan 09 '20 at 06:07
  • can not compile error C2760: syntax error: unexpected token 'identifier', expected ';' – Wiki Wang Jan 09 '20 at 06:10
  • 1
    Try: `typename std::tuple_element>::type i;`. [See here](https://stackoverflow.com/questions/7923369/when-is-the-typename-keyword-necessary) why you need `typename`. – Evg Jan 09 '20 at 06:13
  • thanks and I have [new question](https://stackoverflow.com/questions/59658632/how-to-use-a-type-of-typename), can u help me with that, lol – Wiki Wang Jan 09 '20 at 06:58

0 Answers0