Open
Description
模板类的多个可变参数包解决方案
参考:
- https://stackoverflow.com/questions/37200391/multiple-variadic-parameter-pack-for-template-class
- https://stackoverflow.com/questions/34940875/parameter-pack-must-be-at-the-end-of-the-parameter-list-when-and-why
解决方案
可以使用std::tuple
来进行包装
如下:
template <typename attribute_tuple, APITypes APIType,
typename policy_tuple> class IShader;
template <AttributeType... Attributes, APITypes APIType,
class... Policies>
class IShader<std::tuple<Attributes...>, APIType,
std::tuple<Policies...>> : public Policies... {
// ...
};
可以按照下面的方式来使用模板类:
IShared<std::tuple<Attribute1, Attribute2>, APITypeFoo,
std::tuple<Policy1, Policy2>> ishared_instance;