netgen/libsrc/general/autoptr.hpp

40 lines
985 B
C++
Raw Normal View History

2023-03-13 02:24:21 +05:00
braucht man nicht mehr
2009-01-13 04:40:13 +05:00
#ifndef FILE_AUTOPTR
#define FILE_AUTOPTR
/**************************************************************************/
/* File: autoptr.hpp */
/* Author: STL, Joachim Schoeberl */
/* Date: 29. Dec. 02 */
/**************************************************************************/
2009-07-20 14:36:36 +06:00
namespace netgen
{
2014-09-10 22:15:03 +06:00
/*
2009-01-13 04:40:13 +05:00
template <typename T>
class AutoPtr
{
private:
T * ptr;
public:
typedef T* pT;
explicit AutoPtr (T * p = 0) { ptr = p; }
~AutoPtr () { delete ptr; }
T & operator*() const { return *ptr; }
T* operator->() const { return ptr; }
T *& Ptr() { return ptr; }
T * Ptr() const { return ptr; }
void Reset(T * p = 0) { if (p != ptr) { delete ptr; ptr = p; } }
operator bool () { return ptr != 0; }
private:
AutoPtr (AutoPtr &) { ; }
AutoPtr & operator= (AutoPtr &) { ; }
};
2014-09-10 22:15:03 +06:00
*/
2009-07-20 14:36:36 +06:00
}
2009-01-13 04:40:13 +05:00
#endif