In C++ I have a tuple with some elements in it:
std::tuple my_tuple(3, \'q\');
And some template function that perfectly
Following may help:
template struct caller;
template struct caller>
{
template
void operator() (F f, std::tuple& t, int n)
{
(*this)(f, t, n, std::index_sequence_for());
}
private:
template
void operator() (F f, std::tuple& t, int n, std::index_sequence)
{
std::function&)> fs[] = { &helper... };
fs[n](f, t);
}
template
static void helper(F f, std::tuple& t)
{
f(std::get(t));
}
};
template
void call(F f, T& t, int n)
{
caller()(f, t, n);
}
Live example