C++ One std::vector containing template class of multiple types

前端 未结 5 766
太阳男子
太阳男子 2021-01-31 02:03

I need to store multiple types of a template class in a single vector.

Eg, for:

template 
class templateClass{
     bool someFunction()         


        
5条回答
  •  后悔当初
    2021-01-31 02:29

    The solutions given so far are fine though be aware that in case you were returning the template type other than bool in your example , none of these would help as the vtable slots would not be able to be measured before hand. There are actually limits , from a design point of view , for using a template oriented polymorphic solution.

提交回复
热议问题