Previous post states that you don't NEED to specialize for pointer types, but you might.
Consider the following:
struct Bar {
void bar(void) { /* do work */ }
};
template <class T> struct Foo {
T t;
void foo(void)
{
t.bar(); // If T is a pointer, we should have used operator -> right?
}
};
int main(int argc, char * argv[])
{
Foo<Bar *> t;
t.foo();
}
This won't compile. Because in Foo::foo we have a pointer yet we use it as variable.
If you add the following, it will use the specialization and compile fine:
// This is a pointer to T specialization!
template <class T> class Foo<T *> {
T * t;
public:
void foo(void)
{
t->bar();
}
};