Let's say I have:
template < typename T > class ClassA { void doTheStuff (T const * t); }; template < typename T > class ClassB {
I would like to specialize the doTheStuff method for all instances of the ClassB template as follows:
template <typename T> void ClassA< ClassB< T > >::doTheStuff (ClassB< T > const * t) {
But of course this does not work. Shame, I do not know how I could do this.
With a visual studio compiler, I get:
error C2244: 'ClassA<T>::doTheStuff' : unable to match function definition to an existing declaration see declaration of 'ClassA<T>::doTheStuff' definition 'void ClassA<ClassB<T>>::doTheStuff(const ClassB<T> *)' existing declarations 'void ClassA<T>::doTheStuff(const T *)'
I found this post: Private specialization of a class where the template argument is a template
So, I tried specializing in the whole class, as I advised, but it also does not work:
template <> template < typename U > class ClassA< ClassB< U > > { public: void doTheStuff (ClassB< U > const * b) {
Visual says:
error C2910: 'ClassA<ClassB<U>>' : cannot be explicitly specialized
Any help is appreciated!
Floof.
c ++ templates specialization
Fl
source share