Skip to content

Instantly share code, notes, and snippets.

@kurotych
Last active May 9, 2019 15:27
Show Gist options
  • Save kurotych/e2947297555137f03ec5fce4d5bbc43e to your computer and use it in GitHub Desktop.
Save kurotych/e2947297555137f03ec5fce4d5bbc43e to your computer and use it in GitHub Desktop.
#include <utility>
// C++14
template <int i1, int i2, typename... Args>
auto to_pair(std::tuple<Args...> t)
{
return std::make_pair(std::get<i1>(t), std::get<i2>(t));
}
// C++11
template <int i1, int i2, typename... Args>
auto to_pair(std::tuple<Args...> t)
-> decltype(std::make_pair(std::get<i1>(t),std::get<i2>(t)))
{
return std::make_pair(std::get<i1>(t), std::get<i2>(t));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment