Suppose I have the following function template:
template<typename T>
void mutate(T& t) { /*...*/ }
and I have the following class template:
template<typename... Args>
class Processor {
std::tuple<Args...> tup;
// call mutate on the ith tuple element
void process(size_t i) {
mutate(std::get<i>(tup)); // ERROR
}
}
This doesn't work because the i parameter of process isn't a constant expression. (It can't be a constant expression, because i isn't known until runtime)
Without modifying the signature of process or mutuate, is there some way to efficiently make this work? ie How can I change the implementation of process so that it calls mutate on the ith member of tup?