简体   繁体   中英

Multiple templated variadic templates

I would like to use two templated parameter packs but I do not know how to do it. I read a lot of other StackOverflow posts but not one with templated parameter pack.

template < template < unsigned int > class... EntityList >
struct Entities{};

template < template < unsigned int > class... EntityBuilderList >
struct EntityBuilders{};

template < unsigned int dim, template < unsigned int > class... T >
class CompleteBuilder;

template < unsigned int dim, template < unsigned int > class... EntityList, 
    template < unsigned int > class... EntityBuilderList >
class CompleteBuilder< dim, Entities< EntityList...>, EntityBuilders< EntityBuilderList...> >
    : public EntityBuilderList< dim >...
{};

Then, I would like to use it like CompleteBuilder< 3, Entities< A, B, C >, EntityBuilders< Ab, Bb, Cb > > builder . But I have this error:

error: type/value mismatch at argument 2 in template parameter list for ‘template<unsigned int dim, template<unsigned int <anonymous> > class ... T> class CompleteBuilder’
 class CompleteBuilder< dim, Entities< EntityList...>, EntityBuilders< EntityBuilderList...> >
                                                                                                            ^
note:   expected a class template, got ‘Entities<EntityList ...>’

Thanks for your help

Based on the specialization you have of CompleteBuilder ; your primary template needs to be defined like this

template <unsigned int dim, class... T>
class CompleteBuilder;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM