#ifndef GENERS_CLEARIFPOINTER_HH_ #define GENERS_CLEARIFPOINTER_HH_ namespace gs { template struct ClearIfPointer { static void clear(T&) {} }; template struct ClearIfPointer { static void clear(T*& ptr) {ptr = 0;} }; // The following will set object value to 0 if object is a pointer template void clearIfPointer(T& obj) {ClearIfPointer::clear(obj);} } #endif // GENERS_CLEARIFPOINTER_HH_