I want to create a function that changes multiple values inside a tuple with one call.
template<class... Args>
class EventN {
public:
std::tuple<Args...> mArgs;
EventN(Args... args) : mArgs(args) {}
EventN() {}
template<size_t N> void set(typename std::tuple_element<N-1,Tuple>::type value) {
std::get<N-1>(mArgs) = value; //I use N-1, to start from '1'
}
};
The set function above works as I expect it to:
auto event = new EventN<String,int>();
event->set<1>("testEvent");
event->set<2>(12);
Now, I want to extend the function to:
event->set<1,2>("testEvent", 12);
How can I achieve that? Is there a way to make std::tuple_element<N-1,Tuple>::type
variadic?