📄 warautodestruct.h
字号:
/** */#ifndef WAR_AUTO_DESTRUCT_H#define WAR_AUTO_DESTRUCT_H/* SYSTEM INCLUDES *//* PROJECT INCLUDES *//* LOCAL INCLUDES *//* FORWARD REFERENCES */#ifdef __cplusplusextern "C" {#endif/****************** BEGIN OLD STYLE C spesific ********//****************** END OLD STYLE C spesific **********/#ifdef __cplusplus }#endif/****************** BEGIN C++ spesific ****************/#ifdef __cplusplustemplate <class classT>class WarAutoDestruct {public: typedef classT type_t; // LIFECYCLE /** * Default constructor. */ WarAutoDestruct(type_t *ptr = NULL) : mPtr(ptr) {} /** * Destructor. */ ~WarAutoDestruct() { if (NULL != mPtr) { delete mPtr; mPtr = NULL; } } // OPERATORS type_t *operator = (type_t *ptr) { if (NULL != mPtr) delete mPtr; mPtr = ptr; return ptr; } operator bool () const { return (NULL != mPtr); } operator type_t * () { return mPtr; } // OPERATIONS // CALLBACK // ACCESS type_t * GetPtr() { return mPtr; } // INQUIRY protected: type_t *mPtr;private:};/* INLINE METHODS *//* EXTERNAL REFERENCES */#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif /* WAR_AUTO_DESTRUCT_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -