0
votes

Given the following program:

template <class T>
class A {
    void f();
};

template <class T>
class B { };

template <class T>
void A<B<T> >::f() {

}

I get the error:

invalid use of incomplete type ‘class A<B<T> >’

Does this count as partial specialisation? I always thought partial specialisation was specialising only a struct subset of template parameters.

Is there any work around ao I can accomplish specialising a template with a templated type?

1
A non-partial specialisation is not a template. So if your thing has template parameters, it cannot be a full specialisation. And since it is some kind of specialisation, it's got to be a partial one.Angew is no longer proud of SO
the number of duplicates on this topic is overwhelming. instead of trying to partially specialize a member function just let the overload resolution do the jobPiotr Skotnicki
You can't get a definition for A<int>::f out of that template, so I'd call it partial.jthill

1 Answers

0
votes

it is not possible to partially specialize only one member function, you must specialize whole class

template <class T>
class A {
    void f();
};

template <class T>
class B { };

template <class T>
class A<B<T> >{
    void f() { /* put here what you need in this special case */}; 
};