Multiple Variadic Parameter Pack for Template Class

前端 未结 3 1328
予麋鹿
予麋鹿 2021-02-04 12:44

I am using variadic parameter packs for policy based class design.

template 
class IShader : public Policies... {

};
         


        
3条回答
  •  独厮守ぢ
    2021-02-04 13:47

    In the discussion comments you expressed a willingness to consider some kind of indirection, or "a wrapper of some kind for the attribute list".

    A lightweight std::tuple-based wrapper, together with specialization, might work here:

    template  class IShader;
    
    template 
    class IShader, APIType,
                  std::tuple> : public Policies... {
    
    // ...
    
    };
    

    The goal here is to use a template instance along the lines of:

    IShared, APITypeFoo,
            std::tuple> ishared_instance;
    

    And cross your fingers that this is going to match the specialized template declaration, at which point both parameter packs are available for the template specialization to use, individually.

提交回复
热议问题