Consider the case of a templated function with variadic template arguments:
template Tret func(const T&... t);
template
auto apply_impl(F&& f, Tuple&& t, std::index_sequence) {
return std::forward(f)(std::get(std::forward(t))...);
}
template
auto apply(F&& f, Tuple&& t) {
using Indices = std::make_index_sequence>::value>;
return apply_impl(std::forward(f), std::forward(t), Indices());
}
This is adapted from the C++14 draft using index_sequence. I might propose to have apply in a future standard (TS).