I am having trouble finding information on how to use C ++ 11 variadic TypeLists as containers for portable parameter packages. Suppose I had this piece of code.
#include <type_traits> template <typename T, typename... Ts> struct Index; template <typename T, typename... Ts> struct Index<T, T, Ts...> : std::integral_constant<std::size_t, 0> {}; template <typename T, typename U, typename... Ts> struct Index<T, U, Ts...> : std::integral_constant<std::size_t, 1 + Index<T, Ts...>::value> {};
I can use it to find the first index of a type inside a parameter package like this.
int main() { using namespace std; cout << Index<int, int>::value << endl;
How can I achieve this behavior for TypeList? I am trying to create something like this.
template <typename ...> struct TypeList {}; int main() { using namespace std; using List = TypeList<char, short, long> cout << Index<short, ConvertToParameterPack<List>::types...>::value << endl;
Where ConvertToParameterPack is the method to return the TypeList back to ParameterPack. If what I ask is not possible, are there any other ways to solve this problem?
Brian source share