Last active
October 13, 2018 23:45
-
-
Save kernhanda/524eeadf3df01f6f447ded4545e47e3f to your computer and use it in GitHub Desktop.
Simple snippet to convert a vector to a tuple.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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