Skip to content

Instantly share code, notes, and snippets.

@kim366
Last active May 12, 2019 12:07
Show Gist options
  • Select an option

  • Save kim366/8b71bb21ca9a2919e95acc24cc57a89e to your computer and use it in GitHub Desktop.

Select an option

Save kim366/8b71bb21ca9a2919e95acc24cc57a89e to your computer and use it in GitHub Desktop.
template<typename Op, typename Tuple, std::size_t... Is>
void invoke(Op op, const Tuple& args, std::index_sequence<Is...>)
{
op(std::get<Is>(args)...);
}
template<typename Op, typename... Args>
void invoke(Op op, const std::tuple<Args...>& args)
{
invoke(op, args, std::index_sequence_for<Args...>{});
}
int main()
{
invoke(std::printf, std::make_tuple("%d, %f", 3, 6.1));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment