Feed template function element from tuple at runtime?
问题 In C++ I have a tuple with some elements in it: std::tuple <int, char> my_tuple(3, 'q'); And some template function that perfectly works both on integers and chars: template <class T> void my_function(T); Now, say that at runtime I want to run my_function on one of the elements of my tuple (but I don't know which). I noticed that it is not possible to do something like: unsigned int n; // Give a value to n my_function(std::get <n> (my_tuple)); However, in principle what I need should be