Skip to content

Instantly share code, notes, and snippets.

@kernhanda
Last active October 13, 2018 23:45
Show Gist options
  • Save kernhanda/524eeadf3df01f6f447ded4545e47e3f to your computer and use it in GitHub Desktop.
Save kernhanda/524eeadf3df01f6f447ded4545e47e3f to your computer and use it in GitHub Desktop.
Simple snippet to convert a vector to a tuple.
namespace detail {
template <typename... Args, typename T, size_t... I>
std::tuple<Args...> vector_to_tuple(const std::vector<T>& t, std::index_sequence<I...>) {
return std::tuple<Args...>{ t[I]... };
}
}
template <typename... Args, typename T>
auto vector_to_tuple(const std::vector<T>& t) {
return detail::vector_to_tuple<Args...>(t, std::make_index_sequence<sizeof...(Args)>());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment