Multiple Variadic Parameter Pack for Template Class

前端 未结 3 1329
予麋鹿
予麋鹿 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:28

    Make a nested class, with each layer having one variadic pack. In essence:

    template class Wrapper {
    public:
        template class Type {
            //Here you have access to both template packs
            //...
        }
    }
    //Use like this:
    Wrapper::Type a;
    //...
    

    Define any function of Type outside both classes, but inside the header, or gcc will get confused.

    For a more complete use case, see my answer here

提交回复
热议问题