warautodestruct.h
来自「ftpserver very good sample」· C头文件 代码 · 共 110 行
H
110 行
/** */#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 + =
减小字号Ctrl + -
显示快捷键?