KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am actually trying to see if I can get a minimal library that supports the very few operations I use from boost::fusion. Here is what I have so far... template < typename... Types > struct typelist { }; template < template < typename... > class F, typename... Args > struct apply { typedef typename F < Args... >::type type; }; template < typename, template < typename... > class > struct foreach; template < typename... Types, template < typename Arg > class F > struct foreach < typelist < Types... >, F > { typedef typelist < typename apply < F, Types >::type... > type; }; Since the meta-function foreach implementation is trivial, I thought zip would be easy too. Apparently, this is not the case. template < typename... > struct zip; template < typename... Types0, typename... Types1 > struct zip < typelist < Types0... >, typelist < Types1... > > { typedef typelist < typelist < Types0, Types1 >... > type; }; How can I generalize this zip meta-function to arbitrary number of typelists? What we need here seems to be a parameter pack of parameter packs. I am not sure how to do that. Edit 1: Implementation of is_equal ... template < std::size_t... Nn > struct is_equal; template < std::size_t N0, std::size_t N1, std::size_t... Nn > struct is_equal < N0, N1, Nn... > : and_ < typename is_equal < N0, N1 >::type , typename is_equal < N1, Nn... >::type >::type { }; template < std::size_t M, std::size_t N > struct is_equal < M, N > : std::false_type { typedef std::false_type type; }; template < std::size_t N > struct is_equal < N, N > : std::true_type { typedef std::true_type type; }; A similar approa
Tags (comma-separated)
Save Edits
Cancel