How to force template to be derived from BaseClassA?

前端 未结 3 972
暗喜
暗喜 2020-12-15 20:55

Is there any possibility to force a template to be from a certain base class so that I can call the base class function?

template 
void SomeMan         


        
3条回答
  •  一个人的身影
    2020-12-15 21:31

    Sure, you can combine type traits with SFINAE:

    #include 
    
    template 
    typename std::enable_if::value, void>::type
    SomeManager::Add(T)
    {
        T->CallTsBaseClassFunction();
        //... do other stuff
    }
    

    Although I don't really see the benefit here.

提交回复
热议问题