Last active
February 18, 2022 10:03
-
-
Save buffyanamin/b8ca34aa51e892ff8fb4db2eadd760cb to your computer and use it in GitHub Desktop.
c++ template get nth element type from variadic arguments
This file contains hidden or 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
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