Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:51

0001 #ifndef GENERS_CLEARIFPOINTER_HH_
0002 #define GENERS_CLEARIFPOINTER_HH_
0003 
0004 namespace gs {
0005   template <class T>
0006   struct ClearIfPointer {
0007     static void clear(T &) {}
0008   };
0009 
0010   template <class T>
0011   struct ClearIfPointer<T *> {
0012     static void clear(T *&ptr) { ptr = 0; }
0013   };
0014 
0015   // The following will set object value to 0 if object is a pointer
0016   template <class T>
0017   void clearIfPointer(T &obj) {
0018     ClearIfPointer<T>::clear(obj);
0019   }
0020 }  // namespace gs
0021 
0022 #endif  // GENERS_CLEARIFPOINTER_HH_