   Call static function on pointer template argument
  Hello,I have a function with the following form:template< typename T > T Function() { return T::Function(); }that calls a static function on T.  If T is a pointer to a class, this fails.  What I'd like is for the following to work:A a = Function< A >(); //returns A::Function()B* b = Function< B * >();   //returns B::Function()B could be one of several different classes, so specializing for one class isn't an option.Is there any way to accomplish this?   
  Why not just call A::Function() and B::Function() directly?  What exactly are you trying to accomplish with this?   ;  The simple answer? Don't call Function<B*>(). [grin]Can you provide a bit more detail as to how you're using this?Your other option would be to use boost type traits. You could check the type using is_pointer and then get the base type using remove_pointer.;  The syntax is a little funky, but you could take an approach similar to this:class A{public:static A foo() {return A();};};class B{public:static B foo() {return B();};};template <class T>struct func{T operator()(){return T::foo();}};template <class T>struct func<T*>{T* operator()(){T *t = new T;*t = T::foo();return t;}};int main(){A a = func<A>()();B *b = func<B*>()();};Quote:Original post by ChaosEngineYou could check the type using is_pointer and then get the base type using remove_pointer.I tried using remove_pointer and it worked great.  That's exactly what I was looking for.  Thanks for pointing it out ChaosEngine, I had no idea it existed.  Boost seems to have just about everything.   