diff --git a/inc/hgl/type/Smart.h b/inc/hgl/type/Smart.h index 85d3ee9e..5d52e0d7 100644 --- a/inc/hgl/type/Smart.h +++ b/inc/hgl/type/Smart.h @@ -487,6 +487,51 @@ namespace hgl { obj=nullptr; } + + T *Finish() + { + T *reuslt=obj; + + obj=nullptr; + + return reuslt; + } };//template class AutoDelete + + template class AutoDeleteArray + { + T *obj; + + public: + + AutoDeleteArray(T *o) + { + obj=o; + } + + ~AutoDeleteArray() + { + if(obj) + delete[] obj; + } + + void operator = (T *o) + { + obj=o; + } + + T *operator -> (){return obj;} + + operator T *(){return obj;} + operator const T *()const{return obj;} + + T &operator[](int index){return obj[index];} + const T &operator[](int index)const{return obj[index];} + + void Clear() + { + obj=nullptr; + } + };//template class AutoDeleteArray }//namespace hgl #endif//HGL_SMART_INCLUDE