c++ template casting

后端 未结 7 1205
伪装坚强ぢ
伪装坚强ぢ 2021-01-06 13:48

I\'m a little lost in how to cast templates. I have a function foo which takes a parameter of type ParamVector*. I would like to pass in a P

7条回答
  •  甜味超标
    2021-01-06 14:11

    You can't cast templates like this because the types are unrelated.

    However, you can add a conversion function, such as:

    (Your code wasn't really complete, so I can post complete code either. Hopefully you will get the idea.)

    template class ParamVectorConsumer
    {
     public:
     ParamVector test;
    
     template ParamVectorConsumer convert()
     {
       ParamVectorConsumer ret;
       ret = this->...
    }
    

提交回复
热议问题