Here is my code (of which I'm not sure it's right even):
template<typename... list> struct typeList; template<typename, typename> struct zipper; template<typename...L, typename...R> struct zipper<typeList<L...>, typeList<R...>> { typedef std::tuple<std::pair<L,R>...> tuplez; static_assert(sizeof...(L)==sizeof...(R), "Mismatch number of Args..."); static void print() { std::cout<<"The types are: "<<std::endl; for(int i=0; i<std::tuple_size<tuplez>::value ; ++i) std::cout<< "first : "<< typeid(typename std::tuple_element<i, tuplez>::type::first_type).name()<< "second : "<<typeid(typename std::tuple_element<i, tuplez>::type::second_type).name() <<std::endl; } }; First of all I'm amazed how come my implementation of zipper is so small (must be something wrong I'm damn sure) . If my implementation is wrong, please lemme know why it's wrong rather than giving me solution.
Also If I run this code (zipper<typeList<int,double>, typeList<char,int>>::print();) , I get tons of error : the value of 'i' is not usable in a constant expression (from my gcc 4.7.1)
Here is full list of error (from ideone) with complete code: http://ideone.com/67nxM
P.S : Kindly edit the suitable question title, I couldn't comeup with any more reasonable.
Edit : Thanks to @KerrekSB and @Ugo for suggestions, here is the solution :
template<typename... list> struct typeList; template<int n, typename T> struct printer { static void print (){ std::cout<< "first : "<< typeid(typename std::tuple_element<n, T>::type::first_type).name()<< "second : "<<typeid(typename std::tuple_element<n, T>::type::second_type).name() <<std::endl; printer<n-1,T>::print(); } }; template<typename, typename> struct zipper; template<typename...L, typename...R> struct zipper<typeList<L...>, typeList<R...>> { typedef std::tuple<std::pair<L,R>...> tuplez; static void print(){ printer<std::tuple_size<tuplez>::value-1, tuplez>::print(); } }; template<typename T> struct printer<0,T> { static void print (){ std::cout<< "first : "<< typeid(typename std::tuple_element<0, T>::type::first_type).name()<< "second : "<<typeid(typename std::tuple_element<0, T>::type::second_type).name() <<std::endl; } };
std::tuple_element<i, tuplez>butiis a runtime value - you can't use it in that context.print(), is fine. No need for the static assertion, as this just wouldn't compile with mismatched packs anyway. 2) Non-type template arguments must be compile-time constants. This is just basic template 101 and has nothing to do with the zipping. In TMP you should never have aforloop oversizeof...(Args), but use static recursion. 3) No need to inherit fromtuple, is there?