Skip to content

Instantly share code, notes, and snippets.

@buffyanamin
Last active February 18, 2022 10:03
Show Gist options
  • Save buffyanamin/b8ca34aa51e892ff8fb4db2eadd760cb to your computer and use it in GitHub Desktop.
Save buffyanamin/b8ca34aa51e892ff8fb4db2eadd760cb to your computer and use it in GitHub Desktop.
c++ template get nth element type from variadic arguments
template <std::size_t N, typename T, typename... types>
struct GetNthArgType {
using type = typename GetNthArgType<N - 1, types...>::type;
};
template <typename T, typename... types>
struct GetNthArgType<0, T, types...> {
using type = T;
};
template <typename... Args>
using Get1stArgType_t = typename GetNthArgType<0, Args...>::type;
typename get_Nth_type<0, Args...>::type x;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment