There is a template class:

template<typename Type> class Node : public NodeBase { public: Node( QString name, NodeBase* parent ): NodeBase(name, parent) {} ~Node() {} // ... a lot of methods uses _data virtual QVariant data(int column, int role) const { // ... } virtual bool setData(int column, const QVariant &value, int role) { // ... } private: Type _data; } 

But it would be good to specialize virtual data and setData functions for the case when Type is enum . How can I do that?

I know how to specialize the entire Node class for the enum case, but then you have to rewrite all the other functions that use _data .

  • In C ++ there is no partial specialization of function templates. Therefore, it’s not easy to specialize methods for a group of types. For a particular type (explicit specialization), there is no problem to specialize a separate method, but there is no partial specialization in the language. - AnT

0