多个模板化可变参数模板

时间:2019-01-02 16:35:01

标签: c++ c++11 variadic-templates

我想使用两个模板化的参数包,但我不知道该怎么做。我读了很多其他StackOverflow帖子,但没有阅读带有模板化参数包的帖子。

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 >...
{};

然后,我想像CompleteBuilder< 3, Entities< A, B, C >, EntityBuilders< Ab, Bb, Cb > > builder一样使用它。但是我有这个错误:

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 ...>’

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

根据您对CompleteBuilder的专业知识;您的主要模板需要这样定义

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