c++11 - Merge two variadic templates in one -
im trying implement variadic template wrapper of loki typelist.
merging 2 typelists in loki-style easy, im having problems merge in variadic-template style.
this implementation (simplified, without push_back , index_of , ... , methods).
template<typename... ts> struct dl32typelist; template<typename head , typename... tail> struct dl32typelist<head,tail...> { static const unsigned int size = sizeof...(tail) + 1; using value = dl32loki_like_typelist<head, typename dl32typelist<tail...>::value>; }; template<> struct dl32typelist<> { using value = dl32notype; static const unsignedint size = 0; }; i want like:
template<typename other_typelist> using merge = dl32typelist<head , tail... , typename other_typelist::???>; and problem: cannot store variadic template args using/typedef, have idea how can this. (note other_typelist::???).
i don't know loki or dl32 are, , it's not clear should implementing @ all.
std::tuple common tool type lists. designed runtime storage container works compile-time utility long types complete. here 1 way catenate tuples:
template< typename ... t > struct tuple_cat { typedef decltype( std::tuple_cat( std::declval< t >() ... ) ) type; }; if want manually, try partial specialization:
template< typename ... t > struct type_list {}; template< typename ta, typename tb > struct type_cat; template< typename ... a, typename ... b > struct type_cat< type_list< ... >, type_list< b ... > > { typedef type_list< ..., b ... > type; }; as size member, can make universal metafunction solve problem once , all.
template< typename > struct count_types; template< template< typename ... > class t, typename ... > struct count_types< t< ... > > { static constexpr std::size_t value = sizeof ... a; };
Comments
Post a Comment