0

I have a class A which defines a lot of functions and I want to create a partial specialization of A which defines some more functions. I've read about a class inheriting itself but only with full specialization. So

template<typename T>
struct A
{
    void foo() {...}
    void bar() {...}
};

template<typename T>
struct A<T*> : A<T*> // a class cannot be its own base class, here I want to inherit A without partial specialization
{
   void baz() {...}
};
user7769147
  • 1,559
  • 9
  • 15
  • This cannot be done in C++ as is. Although there are several workaround they all have one or other kind of problems. You need to redesign your class hierarchy to avoid this issue completely. – Sam Varshavchik Nov 28 '19 at 15:30
  • 1
    Create another template and move A's members to it. Then inherit both the primary template A and the specializations from it. – HolyBlackCat Nov 28 '19 at 15:31

0 Answers0